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 | }
|