-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Can Query translator ignore part of hql while parsing?
PostPosted: Wed Sep 10, 2008 10:59 am 
Newbie

Joined: Wed Sep 10, 2008 9:34 am
Posts: 1
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.