-->
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: Need to Convert SQL Query to HQL (join ON)...
PostPosted: Wed Aug 31, 2005 6:09 pm 
Newbie

Joined: Wed Aug 31, 2005 5:56 pm
Posts: 5
I need to convert this SQL Query to a Hibernate QL...
I have Problems withe the Keyword "ON"... HQL doesn't take it. Is there a way to work arround the "ON"?

And can I get a Resultlist of the three Entities (Table1 , Table2 and Table3) at once.. Perhaps like an Array Object?


//...

q = em.createQuery("FROM Table1 t, Table2 a, Table3 d JOIN Table2 ON (t.id = a.id) FULL JOIN Table3 ON (t.id = .id) WHERE (ASta BETWEEN ? AND ?) OR (DStd BETWEEN ? AND ?)");

q.setParameter(0, orp.getStartTime());
q.setParameter(1, orp.getEndTime());
q.setParameter(2, orp.getStartTime());
q.setParameter(3, orp.getEndTime());

//...

Thanks very much for your help... I really can't figure it out...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 6:31 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
could you post the mappings for objects Table1, Table2 and Table3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 6:53 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
There is no ON clause in HQL. The associations are taken from your mapping. If you need further restrictions to a specific join conditions, you can take the "new" HQL keywords WITH (since Hibernate 3.1 beta 2) or put the restrictions into the WHERE clause.

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


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.