-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mysql date_add
PostPosted: Fri Dec 21, 2007 4:21 am 
Newbie

Joined: Fri Dec 21, 2007 4:09 am
Posts: 1
hi all ... need some help here


i am using hibernate3 with mysql function date_add ... but getting exception below .... any idea whether date_add function is supported in hibernate???


[20/12/2007 22:11:30] - org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: from com....hibernate.ProcessDate where ID <= :pdId and dateEnd >= date_add(curdate(), interval -3 month) order by dateEnd desc

[20/12/2007 22:11:30] - org.hibernate.hql.ast.ErrorCounter - line 1:113: unexpected token: month

[20/12/2007 22:11:30] - org.hibernate.hql.ast.ErrorCounter - line 1:113: unexpected token: month


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 21, 2007 6:20 am 
Regular
Regular

Joined: Sat Nov 25, 2006 11:37 am
Posts: 72
According to http://www.hibernate.org/hib_docs/v3/re ... xpressions Hibernate supports any scalar function supported by the database system. However, because Hibernate needs to parse your query it must be well formed with respect to the HQL syntax. 'interval -3 month' is not a valid expression in HQL. So, date_add() is supported but not the MySQL specific expression syntax associated with the second argument. I am not sure if there is a solution other then to use a native query and not HQL. You could try and substitute it as a query parameter.


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

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.