Issue with Hibernate 6.4 for an HQL

I have an HQL which worked fine prior to Hibernate 6, after upgrading to hibernate 6.4 now I am getting below exception
org.hibernate.query.SemanticException: Operand of - is of type ‘java.lang.Integer’ which is not a temporal amount it is not an instance of ‘java.time.TemporalAmount’
sample query which is causing this issue
createDate <(SYSDATE- 120 SECOND)
the database is oracle and createDate datatype is Timestamp

Try putting parenthesis around the temporal amount i.e. createDate < current_timestamp - (120 second)

To kynect@2011ashwini ,

To resolve this issue, you can adjust your HQL query to correctly handle date arithmetic in a way that Hibernate 6.4 understands. Option 1 is Use SQL Functions. Hibernate provides access to SQL functions directly in HQL queries, which can be used to perform date arithmetic. Option 2 is Use Hibernate’s INTERVAL Function (if supported). Some versions of Hibernate support the INTERVAL function for defining date intervals directly in HQL.

1 Like