我正在使用这个例子: http://www.mkyong.com/hibernate/hibernate-query-examples-hql/
试图删除这种方式:
String qhl = "delete from logs where dateTtime >= current_date - interval '1 month'";
Query query = session.createQuery(hql);
return query.executeUpdate();
但是我收到了这个错误:
ERROR: line 1:61: unexpected token: '1 month'
Mai 23, 2014 3:07:22 PM org.hibernate.hql.internal.ast.ErrorCounter reportError
ERROR: line 1:61: unexpected token: '1 month'
line 1:61: unexpected token: '1 month'
at org.hibernate.hql.internal.antlr.HqlBaseParser.identPrimary(HqlBaseParser.java:4016)
at org.hibernate.hql.internal.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:859)
at org.hibernate.hql.internal.antlr.HqlBaseParser.atom(HqlBaseParser.java:3390)
at org.hibernate.hql.internal.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3168)
...
尝试时:
String qhl = "delete from logs where dateTtime >= ( select cast(date_trunc('month', current_date) as date) )";
错误是:
logs is not mapped [delete from logs where dateTtime >= ( select cast(date_trunc('month', current_date) as date) )]
我做错了什么?