fix for datetime subtraction on DB2
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
064526a5c6
commit
ac40e37700
|
@ -476,7 +476,11 @@ public class DB2Dialect extends Dialect {
|
||||||
switch ( unit ) {
|
switch ( unit ) {
|
||||||
case NATIVE:
|
case NATIVE:
|
||||||
case NANOSECOND:
|
case NANOSECOND:
|
||||||
pattern.append( "(seconds_between(" );
|
pattern.append( "(seconds_between(date_trunc('second'," );
|
||||||
|
pattern.append( toExpression );
|
||||||
|
pattern.append( "),date_trunc('second'," );
|
||||||
|
pattern.append( fromExpression );
|
||||||
|
pattern.append( "))" );
|
||||||
break;
|
break;
|
||||||
//note: DB2 does have weeks_between()
|
//note: DB2 does have weeks_between()
|
||||||
case MONTH:
|
case MONTH:
|
||||||
|
@ -484,14 +488,18 @@ public class DB2Dialect extends Dialect {
|
||||||
// the months_between() function results
|
// the months_between() function results
|
||||||
// in a non-integral value, so trunc() it
|
// in a non-integral value, so trunc() it
|
||||||
pattern.append( "trunc(months_between(" );
|
pattern.append( "trunc(months_between(" );
|
||||||
break;
|
|
||||||
default:
|
|
||||||
pattern.append( "?1s_between(" );
|
|
||||||
}
|
|
||||||
pattern.append( toExpression );
|
pattern.append( toExpression );
|
||||||
pattern.append( ',' );
|
pattern.append( ',' );
|
||||||
pattern.append( fromExpression );
|
pattern.append( fromExpression );
|
||||||
pattern.append( ')' );
|
pattern.append( ')' );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pattern.append( "?1s_between(" );
|
||||||
|
pattern.append( toExpression );
|
||||||
|
pattern.append( ',' );
|
||||||
|
pattern.append( fromExpression );
|
||||||
|
pattern.append( ')' );
|
||||||
|
}
|
||||||
switch ( unit ) {
|
switch ( unit ) {
|
||||||
case NATIVE:
|
case NATIVE:
|
||||||
pattern.append( "+(microsecond(");
|
pattern.append( "+(microsecond(");
|
||||||
|
|
Loading…
Reference in New Issue