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: void testDialectSQLFunctions()
|
Method name: void testDialectSQLFunctions()
|
|||
Number of AST nodes: 15 | Number of AST nodes: 15 | |||
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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 225 |
Number of mapped statements | 14 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 67.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 | if (getDialect() instanceof Cache71Dialect) |
| 15 | if (getDialect() instanceof Oracle9iDialect) | |||||||||||||
16 | java.util.List rset = s.find("select s.name, sysdate, floor(s.pay), round(s.pay,0) from Simple s"); |
| 16 | java.util.List rset = s.find("select s.name, sysdate(), trunc(s.pay), round(s.pay) from Simple s"); | |||||||||||||
17 | assertNotNull("Name string should have been returned", (((Object[])rset.get(0))[0])); | 17 | assertNotNull("Name string should have been returned", (((Object[])rset.get(0))[0])); | ||||||||||||||
18 | assertNotNull("Todays Date should have been returned", (((Object[])rset.get(0))[1])); | 18 | assertNotNull("Todays Date should have been returned", (((Object[])rset.get(0))[1])); | ||||||||||||||
19 | assertEquals("floor(45.8) result was incorrect ", new Integer(45), ((Object[])rset.get(0))[2]); |
| 19 | assertEquals("trunc(45.8) result was incorrect ", new Float(45), ((Object[])rset.get(0))[2]); | |||||||||||||
20 | assertEquals("round(45.8) result was incorrect ", new Float(46), ((Object[])rset.get(0))[3]); | 20 | assertEquals("round(45.8) result was incorrect ", new Float(46), ((Object[])rset.get(0))[3]); | ||||||||||||||
21 | simple.setPay(new Float(-45.8)); | 21 | simple.setPay(new Float(-45.8)); | ||||||||||||||
22 | s.update(simple); | 22 | s.update(simple); | ||||||||||||||
23 | rset = s.find("select abs(round(s.pay,0)) from Simple s"); |
| 23 | rset = s.find("select abs(round(s.pay)) from Simple s"); | |||||||||||||
24 | assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0)); | 24 | assertEquals("abs(round(-45.8)) result was incorrect ", new Float(46), rset.get(0)); | ||||||||||||||
25 | assertTrue(s.find("select floor(round(sysdate,1)) from Simple s").size() == 1); |
| 25 | assertTrue(s.find("select trunc(round(sysdate())) from Simple s").size() == 1); | |||||||||||||
26 | simple.setPay(null); | 26 | simple.setPay(null); | ||||||||||||||
27 | s.update(simple); | 27 | s.update(simple); | ||||||||||||||
|
| 28 | Integer value = (Integer)s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0); | ||||||||||||||
28 | Double value = (Double)s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0); |
| | ||||||||||||||
29 | assertTrue(0 == value.intValue()); |
| 29 | assertTrue(0 == value.intValue()); |
Row | Violation |
---|---|
1 | Unmatched statement Integer value=(Integer)s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement Integer value=(Integer)s.find("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").get(0); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
3 | Unmatched statement Double value=(Double)s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement Double value=(Double)s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |