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.  [ 3 posts ] 
Author Message
 Post subject: SQL to HQL
PostPosted: Tue Sep 05, 2006 4:07 am 
Newbie

Joined: Mon Sep 04, 2006 10:45 am
Posts: 3
I have an SQL query and i want to convert it into a HQL query:

SELECT MESSAGES.MESSAGEID, MESSAGES.TYPE, MESSAGES.AREA, MESSAGES.FLOW, MESSAGES.OTHERFLOWINFO,
MESSAGES.DATECREATED, MESSAGES.DATELASTUPDATED, MESSAGES.CONTEXT, MESSAGES.STATUS, MESSAGES.PARENT,
PROBTRACKING.USERID
FROM MESSAGES
LEFT OUTER JOIN PROBTRACKING
ON MESSAGES.MESSAGEID = PROBTRACKING.MESSAGEID
AND PROBTRACKING.PROBLEMSTATUS = 'Unresolved'

Can this be done, i don't want to use create SQL query for this as i have filters set up, Struggling a lot with the syntax!

Any help is much appreciated,

Thanks


Top
 Profile  
 
 Post subject: Re: SQL to HQL
PostPosted: Tue Sep 05, 2006 8:06 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
I'm not aware of any tool that does this, but there is a tool that works the other way around: http://www.ayende.com/projects/nhibernate-query-analyzer.aspx. This at least gives you an opportunity to play around with HQL and directly see its SQl translation. It should not be too hard to enter HQL that exactly produces a query like the one you entered.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 05, 2006 10:42 am 
Newbie

Joined: Thu Apr 13, 2006 9:26 am
Posts: 9
Hello,

this particular query cannot be written in HQL because of lack of support of the "where" keyword introduced in Hibernate 3.0. See http://jira.nhibernate.org/browse/NH-514 for details.

I have written an ugly hack as I want to keep my request in HQL: I translate the HQL request to SQL (thanks to Ayende for the NQA code availability) then insert my "on" statement after the "outer join" statement and then execute the query... It is well encapsulated and so not that ugly but still support for the "where" keyword in NH would of course be nicer!

Regards,


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