I am trying to execute this hql
SELECT DATE_TRUNC('DAY', aVO.endDate at time zone 'EDT') at time zone 'EDT' FROM com.vo aVO;
And it fails
An equivalent sql (the one that is supposed to be generated for postgresql) works fine
select date_trunc('day', end_date at time zone 'EDT') at time zone 'EDT' from vo_table;
I got the date_trunc function for postgresql registered by subclassing the dialect and doing.
super.registerFunction("date_trunc", new StandardSQLFunction("date_trunc", Hibernate.TIMESTAMP));
However if I take out the "at Time zone 'EDT'" part from both the places, the hql works fine.
Can anyone think of a workaround please?
Thanks for your help.
Hibernate version:3.2.5
Full stack trace of any exception that occurs: org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: at near line 1, column 38 [SELECT DATE_TRUNC('DAY', aVO.endDate at time zone 'EDT') at time zone 'EDT' FROM com.vo aVO] org.hibernate.hql.ast.QuerySyntaxException: unexpected token: at near line 1, column 42 [SELECT DATE_TRUNC('DAY', aVO.endDate at time zone 'EDT') at time zone 'EDT' FROM com.vo aVO] at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31) at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24) at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1205) at $Proxy3.createQuery(Unknown Source)
Name and version of the database you are using: postgreSQL 8.2
Debug level Hibernate log excerpt: 2008-09-10 15:44:41,380 ERROR ErrorCounter line 1:42: unexpected token: at 2008-09-10 15:44:41,396 DEBUG ErrorCounter line 1:42: unexpected token: at line 1:42: unexpected token: at at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3520) at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3216) at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3098) at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2818)
|