-->
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.  [ 4 posts ] 
Author Message
 Post subject: NewBie Question about querying
PostPosted: Tue Sep 20, 2005 5:21 pm 
Beginner
Beginner

Joined: Mon Sep 26, 2005 5:57 pm
Posts: 39
Let us say we have a Order class that has a collection of Items.

I would like to query for all Orders that have a particular Item in its Items collection. I definitely want to use the Order class as the entry class for the criteria. How can I do that?


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 5:24 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try this (in the new 1.0-rc1 version):
Code:
ISession
  .CreateCriteria(typeof(Order))
    .CreateCriteria(typeof(Item))
      .Add(Expression.Eq("id", itemId))
  .List();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 3:27 pm 
Newbie

Joined: Tue Sep 06, 2005 11:41 pm
Posts: 7
Location: New York
You can also try this (as HQL):

Code:
select order
from myNamespace.Orders as order
inner join order.Items as item
where item.Id = ....

Obviously, insert the Id of your item where the dots are. Hope this helps; I've spent all day working it out for myself :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 10:14 am 
sergey wrote:
Try this (in the new 1.0-rc1 version):
Code:
ISession
  .CreateCriteria(typeof(Order))
    .CreateCriteria(typeof(Item))
      .Add(Expression.Eq("id", itemId))
  .List();


I already install the 1.0-rc1 version and I get an error on the second createCriteria, a string parameter is expected. any help would be appreciate


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