ERROR - org.hibernate.exception.SQLGrammarException: could not execute query caused by java.sql.SQLSyntaxErrorException: ORA-01722: invalid number while using Hibernate, Criteria , Restriction.between and Date

Error

org.hibernate.exception.SQLGrammarException: could not execute query 


caused by 

java.sql.SQLSyntaxErrorException: ORA-01722: invalid number while using Hibernate, Criteria , Restriction.between and Date

Error Type

Runtime

Cause

Restriction.between doesn't work on date with Criteria but works fine with HQL.

Resolution 

Either change it to HQL or add multiple Restrictions to specify less than and greater than.

Restrictions.lt and Restriction.gt instead of Restrictions.between