-->
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: HQL Query to Pull Entities and All Child Entities
PostPosted: Thu Jun 14, 2007 10:32 am 
Newbie

Joined: Tue Jul 26, 2005 10:25 am
Posts: 12
Okay, suppose I have a simple POJO class like this:

Code:
@Entitiy
@Table(name="T_ORGANIZATION")
public class Organization {

     private int organizationId;
     private Collection childOrganizations;

     @Id
     @GeneratedValue
     @Column(name="organization_id")
     public int getOrganizationId() {
         return this.organizationId;
     }

     public void setOrganizationId(int id) {
         this.organizationId = id;
     }

     // Assume this is mapped correctly
     public Collection getChildOrganizations() {
         return this.childOrganizations;
     }

     public void setChildOrganizations(Collection children) {
          this.childOrganizations=children;
     }

     // Assume equals() and hashCode() are overriden here
}


What would be a good HQL query to pull all of the child organizations (and their child organizations, etc) into a single collection?

Jason


Top
 Profile  
 
 Post subject: Re:
PostPosted: Thu Jun 14, 2007 3:18 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
A set instead of a collection could be a good choice. IF the set is mapped in mapping file, when the org is loaded, all the children will also get loaded, subject to lazy attribute setting.


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.