-->
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 help request.
PostPosted: Mon Aug 15, 2005 4:36 pm 
SELECT * FROM Order WHERE OrderID IN (
SELECT DISTINCT ORderID FROM OrderDetail WHERE OrderDetailStatusID IN (1,2,3,4,5))
AND Order.VendorID=1 AND Order.SalesDate>'01.02.2004'

hi,
how can i write the hql replacement of above query?

thanx a lot.


Top
  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 4:23 am 
what a helpful community!


Top
  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 5:01 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Why don't you just try it yourself, tell us what you came up with, and what was the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 11:02 am 
i can understand what you say.
but i have no experience with hql queries with joins.

thank you.


Top
  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 6:17 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
It may depend on how your tables are related, and whether that relationship is reflected as an association in your object mappings.

Assuming the Order object has a collection of OrderDetail objects, this might work (or might not):

Code:
from Order order where order.Details.StatusID in (1,2,3,4,5) and order.VendorID = 1 and order.SalesDate > '01.02.2004'


I've never had much luck with dates as strings in HQL, so I would use a named parameter ":dateVal" in creating an IQuery, then set the parameter using a DateTime object.

The names of the objects and properties I used were arbitrary, and would depend on the mapping files matching the object to the table.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 11:40 am 
your message so illuminated my way.

thanks a lot.


Top
  
 
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.