if ( getDialect() instanceof Cache71Dialect) { // Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions java.util.List rset = s.find("select s.name, sysdate, floor(s.pay), round(s.pay,0) from Simple s"); assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0])); assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1])); assertEquals("floor(45.8) result was incorrect ", new Integer(45), ( (Object[]) rset.get(0) )[2] ); assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] ); simple.setPay(new Float(-45.8)); s.update(simple); // Test type conversions while using nested functions (Float to Int). rset = s.find("select abs(round(s.pay,0)) from Simple s"); assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0)); // Test a larger depth 3 function example - Not a useful combo other than for testing assertTrue( s.find("select floor(round(sysdate,1)) from Simple s").size() == 1 ); // Test the oracle standard NVL funtion as a test of multi-param functions... simple.setPay(null); s.update(simple); Double value = (Double) s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0); assertTrue( 0 == value.intValue() ); }
if ( getDialect() instanceof Oracle9iDialect ) { // Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions java.util.List rset = s.find("select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s"); assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0])); assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1])); assertEquals("trunc(45.8) result was incorrect ", new Float(45), ( (Object[]) rset.get(0) )[2] ); assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] ); simple.setPay(new Float(-45.8)); s.update(simple); // Test type conversions while using nested functions (Float to Int). rset = s.find("select abs(round(s.pay)) from Simple s"); assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0)); // Test a larger depth 3 function example - Not a useful combo other than for testing assertTrue( s.find("select trunc(round(sysdate())) from Simple s").size() == 1 ); // Test the oracle standard NVL funtion as a test of multi-param functions... simple.setPay(null); s.update(simple); Integer value = (Integer) s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0); assertTrue( 0 == value.intValue() ); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/dialect/functional/cache/SQLFunctionsInterSystemsTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
if ( getDialect() instanceof Cache71Dialect) {
1
if ( getDialect() instanceof Oracle9iDialect ) {
2
			// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
2
			// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
3
			java.util.List rset = s.find("select s.name, sysdate, floor(s.pay), round(s.pay,0) from Simple s");
3
			java.util.List rset = s.find("select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s");
4
			assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0]));
4
			assertNotNull("Name string should have been returned",(((Object[])rset.get(0))[0]));
5
			assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1]));
5
			assertNotNull("Todays Date should have been returned",(((Object[])rset.get(0))[1]));
6
			assertEquals("floor(45.8) result was incorrect ", new Integer(45), ( (Object[]) rset.get(0) )[2] );
6
			assertEquals("trunc(45.8) result was incorrect ", new Float(45), ( (Object[]) rset.get(0) )[2] );
7
			assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] );
7
			assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] );
8

9
			simple.setPay(new Float(-45.8));
8
			simple.setPay(new Float(-45.8));
10
			s.update(simple);
9
			s.update(simple);
11

12
			// Test type conversions while using nested functions (Float to Int).
10
			// Test type conversions while using nested functions (Float to Int).
13
			rset = s.find("select abs(round(s.pay,0)) from Simple s");
11
			rset = s.find("select abs(round(s.pay)) from Simple s");
14
			assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0));
12
			assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0));
15

16
			// Test a larger depth 3 function example - Not a useful combo other than for testing
13
			// Test a larger depth 3 function example - Not a useful combo other than for testing
17
			assertTrue(
14
			assertTrue(
18
				s.find("select floor(round(sysdate,1)) from Simple s").size() == 1
15
				s.find("select trunc(round(sysdate())) from Simple s").size() == 1
19
			);
16
			);
20

21
			// Test the oracle standard NVL funtion as a test of multi-param functions...
17
			// Test the oracle standard NVL funtion as a test of multi-param functions...
22
			simple.setPay(null);
18
			simple.setPay(null);
23
			s.update(simple);
19
			s.update(simple);
24
			Double value = (Double) s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0);
20
			Integer value = (Integer) s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0);
25
			assertTrue( 0 == value.intValue() );
21
			assertTrue( 0 == value.intValue() );
26
		}
22
		}
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0