Author: gbadner
Date: 2008-09-29 17:39:00 -0400 (Mon, 29 Sep 2008)
New Revision: 15226
Modified:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
JBPAPP-948 HHH-3501 : ASTParserLoadingTest testing unsupported queries for DB2
Modified:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
---
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2008-09-29
21:36:27 UTC (rev 15225)
+++
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2008-09-29
21:39:00 UTC (rev 15226)
@@ -167,13 +167,29 @@
s.beginTransaction();
s.createQuery( "from Animal a where abs(a.bodyWeight-:param) < 2.0"
).setLong( "param", 1 ).list();
s.createQuery( "from Animal a where abs(:param - a.bodyWeight) < 2.0"
).setLong( "param", 1 ).list();
- if ( ! ( getDialect() instanceof HSQLDialect ) ) {
- // HSQLDB does not like the abs(? - ?) syntax...
+ if ( ( getDialect() instanceof HSQLDialect ) || ( getDialect() instanceof DB2Dialect )
) {
+ // HSQLDB and DB2 don't like the abs(? - ?) syntax. bit work if at least one
parameter is typed...
+ s.createQuery( "from Animal where abs(cast(:x as long) - :y) < 2.0"
).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ s.createQuery( "from Animal where abs(:x - cast(:y as long)) < 2.0"
).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ s.createQuery( "from Animal where abs(cast(:x as long) - cast(:y as long)) <
2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
+ }
+ else {
s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong(
"x", 1 ).setLong( "y", 1 ).list();
}
- s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'"
).setString( "foo", "foo" ).list();
+
+ if ( getDialect() instanceof DB2Dialect ) {
+ s.createQuery( "from Animal where lower(upper(cast(:foo as string))) like
'f%'" ).setString( "foo", "foo" ).list();
+ }
+ else {
+ s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'"
).setString( "foo", "foo" ).list();
+ }
s.createQuery( "from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) *
abs(length('ffobar')-3)) = 3.0" ).setLong( "param", 1 ).list();
- s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like
'f%'" ).setString( "bar", "xyz" ).list();
+ if ( getDialect() instanceof DB2Dialect ) {
+ s.createQuery( "from Animal where lower(upper('foo') || upper(cast(:bar
as string))) like 'f%'" ).setString( "bar", "xyz"
).list();
+ }
+ else {
+ s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like
'f%'" ).setString( "bar", "xyz" ).list();
+ }
if ( ! ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof
MySQLDialect ) ) {
s.createQuery( "from Animal where abs(cast(1 as float) - cast(:param as float)) =
1.0" ).setLong( "param", 1 ).list();
}
Show replies by date