Я использую HQL с DATE_ADD (функция mysql), как показано ниже
String hql =
"select count(*) " +
"from ProgramGroupEvent as eventLog " +
"where eventLog.id= :id" +
"and DATE_ADD( eventLog.eventDate, INTERVAL :interval MINUTE) > now()";
long count = 0;
try {
count = ((Long)sess.createQuery( hql )
.setLong( "id", id)
.setInteger("interval", interval )
.iterate().next()).longValue();
} catch (HibernateException e) {
e.printStackTrace();
}
Но Hibernate выдает ошибку токена, как показано ниже
antlr.NoViableAltException: unexpected token: :
at org.hibernate.hql.internal.antlr.HqlBaseParser.identPrimary(HqlBaseParser.java:4016) ~[hibernate-core-4.1.7.Final.jar:4.1.7.Final]
at org.hibernate.hql.internal.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:859) ~[hibernate-core-4.1.7.Final.jar:4.1.7.Final]
at org.hibernate.hql.internal.antlr.HqlBaseParser.atom(HqlBaseParser.java:3390) ~[hibernate-core-4.1.7.Final.jar:4.1.7.Final]
PS: я использую Hibernate 4.1.7