-->
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.  [ 6 posts ] 
Author Message
 Post subject: HQL Query
PostPosted: Mon Nov 14, 2005 6:12 pm 
Newbie

Joined: Thu Jul 28, 2005 1:22 pm
Posts: 3
I've got a query I need to execute on an Informix database. The SQL given to me to implement in my HQL contains the following clause:


Code:
OR (p.swdatecreated + 120 UNITS DAY) >= CURRENT


I get the following error for this query:

Code:
org.hibernate.hql.ast.QuerySyntaxError: unexpected token: DAY near line 51, column 90 [   


Any ideas how I can implement this type of clause with HQL?

Thanks,
David


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 6:27 pm 
Beginner
Beginner

Joined: Tue Oct 18, 2005 3:57 pm
Posts: 48
Location: Los Angeles, CA
HQL has its own syntax while your query is Informix-specific. Try Session.createSQLQuery(...) instead.

jd


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 8:33 pm 
Newbie

Joined: Thu Jul 28, 2005 1:22 pm
Posts: 3
jd001982 wrote:
HQL has its own syntax while your query is Informix-specific. Try Session.createSQLQuery(...) instead.

jd


Thanks for the feedback. Is there some way for me to rewrite this clause logic in HQL (i.e. date1 + 120 days >= date2)?

David


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 9:23 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
you will must use native sql for informix, probably


Top
 Profile  
 
 Post subject: Re: HQL Query
PostPosted: Tue Nov 15, 2005 4:04 am 
Regular
Regular

Joined: Sat Nov 05, 2005 5:33 am
Posts: 70
Location: Linz, Austria
davidwsica wrote:
I've got a query I need to execute on an Informix database. The SQL given to me to implement in my HQL contains the following clause:


Code:
OR (p.swdatecreated + 120 UNITS DAY) >= CURRENT


I get the following error for this query:

Code:
org.hibernate.hql.ast.QuerySyntaxError: unexpected token: DAY near line 51, column 90 [   


Any ideas how I can implement this type of clause with HQL?


Is CURRENT some built in function for the current date?

Then you're lucky.
Code:
OR p.swdatecreated >= :current

and
Code:
Calendar c = new GregorianCalendar();
c.add(Calendar.DATE, -120);
q.setCalendar("current", c);

[/code]

_________________
hth,
Heinz
Don't forget to rate if this helped


Top
 Profile  
 
 Post subject: Re: HQL Query
PostPosted: Tue Nov 15, 2005 4:55 pm 
Newbie

Joined: Thu Jul 28, 2005 1:22 pm
Posts: 3
hhuber wrote:
davidwsica wrote:
I've got a query I need to execute on an Informix database. The SQL given to me to implement in my HQL contains the following clause:


Code:
OR (p.swdatecreated + 120 UNITS DAY) >= CURRENT


I get the following error for this query:

Code:
org.hibernate.hql.ast.QuerySyntaxError: unexpected token: DAY near line 51, column 90 [   


Any ideas how I can implement this type of clause with HQL?


Is CURRENT some built in function for the current date?

Then you're lucky.
Code:
OR p.swdatecreated >= :current

and
Code:
Calendar c = new GregorianCalendar();
c.add(Calendar.DATE, -120);
q.setCalendar("current", c);

[/code]


Thanks, actually this solution occured to me just prior to reading your suggestion. I'm glad I can avoid native SQL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.