HHH-16035 fix bug with Durations magnitude being off by 10^9

This commit is contained in:
Gavin 2023-01-13 14:54:20 +01:00 committed by Gavin King
parent 2f5f5b9a50
commit 43cce5fe5e
1 changed files with 3 additions and 3 deletions

View File

@ -412,6 +412,7 @@ import static org.hibernate.query.sqm.BinaryArithmeticOperator.ADD;
import static org.hibernate.query.sqm.BinaryArithmeticOperator.MULTIPLY;
import static org.hibernate.query.sqm.BinaryArithmeticOperator.SUBTRACT;
import static org.hibernate.query.sqm.TemporalUnit.EPOCH;
import static org.hibernate.query.sqm.TemporalUnit.NANOSECOND;
import static org.hibernate.query.sqm.TemporalUnit.NATIVE;
import static org.hibernate.query.sqm.TemporalUnit.SECOND;
import static org.hibernate.query.sqm.UnaryArithmeticOperator.UNARY_MINUS;
@ -4032,9 +4033,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
);
}
else {
// The absolute value of the expression is in seconds
// as the fractional seconds are in the fraction part as can be seen in DurationJavaType
duration = new Duration( scaledExpression, SECOND, (BasicValuedMapping) durationType );
// Durations are stored as nanoseconds (see DurationJavaType)
duration = new Duration( scaledExpression, NANOSECOND, (BasicValuedMapping) durationType );
}
TemporalUnit appliedUnit = appliedByUnit.getUnit().getUnit();