-->
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.  [ 2 posts ] 
Author Message
 Post subject: one-to-many relationship
PostPosted: Thu Aug 30, 2007 3:44 pm 
Newbie

Joined: Thu Aug 30, 2007 3:17 pm
Posts: 1
Hi,

I have two tables ORDER and PRODUCT and they have a one-to-many relationship.

This is the code from the mapping file :

Code:
<class>
           <set inverse="true" name="ProductsSet"  lazy="false">
   <key column="ORDER_ID" />
   <one-to-many class="Products" />
          </set>
</class>


Is it possible using HQL to retrieve records by applying conditions on both parent and child for example i want to get all Orders with quantity field > 2 and only Products for that Order that have a status field = 'A'

Thanks in advance


Top
 Profile  
 
 Post subject: Re: one-to-many relationship
PostPosted: Thu Aug 30, 2007 4:54 pm 
Beginner
Beginner

Joined: Tue Oct 10, 2006 3:23 am
Posts: 33
I think you want to use a filter on your collection,
look at session.enableFilter('filterName')

* rate if this helps *

divya_sree wrote:
Hi,

I have two tables ORDER and PRODUCT and they have a one-to-many relationship.

This is the code from the mapping file :

Code:
<class>
           <set inverse="true" name="ProductsSet"  lazy="false">
   <key column="ORDER_ID" />
   <one-to-many class="Products" />
          </set>
</class>


Is it possible using HQL to retrieve records by applying conditions on both parent and child for example i want to get all Orders with quantity field > 2 and only Products for that Order that have a status field = 'A'

Thanks in advance


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