-->
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: A Component with a Collection Property?
PostPosted: Wed Jun 09, 2004 4:53 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:21 pm
Posts: 40
Location: Honolulu, HI
Hello,

I read in the documentation:

" The properties of a component may be of any Hibernate type (collections, many-to-one associations, other components, etc). "

from

http://www.hibernate.org/hib_docs/refer ... nents.html

I'm not able to find an example of a component with a collection as a property. Is this possible, and if so, an example would be most helpful.

Thanks very much!
Seth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 6:49 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:21 pm
Posts: 40
Location: Honolulu, HI
Here is an example:

<component class="eg.Child" name="child">
<property name="name" column="child_name"/>
<set name="addrs" table="ADDR" lazy="true">
<key column="parent_id" />
<composite-element class="eg.Addr">
<property name="street1"/>
<property name="city"/>
</composite-element>
</set>
</component>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 12:13 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Does it work even if the collection contains many-to-many associations?

something like that:

Code:
<component class="eg.Child" name="child">
   <property name="name" column="child_name"/>
   <set name="addrs" table="ADDR" lazy="true">
       <key column="parent_id" />
       <many-to-many class="eg.Addr"/>
   </set>
</component>


Thanks

Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, check the DTD, it helps

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 1:05 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
In fact I have a problem with some queries.

I have a mapping that looks like that:
Code:
<class name="eg.Parent">
  <id name="id" column="ParentId" type="long">
      <generator class="native"/>
  </id>
  <component class="eg.Child" name="child">
   <property name="name" column="child_name"/>
   <set name="addrs" table="ADDR" lazy="true">
       <key column="parent_id" />
       <many-to-many class="eg.Addr"/>
   </set>
  </component>
</class>


Then when I do such a query
Code:
select parent.child from eg.Parent parent 
join parent.child.addrs addr where (addr.name in ( 'name1'))

The query seem to works (the 'where' part) but the returned Child objects doesn't contains the addrs collection.

Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 30, 2004 9:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
join fetch

_________________
Emmanuel


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