-->
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.  [ 1 post ] 
Author Message
 Post subject: ternary association to a collection of values
PostPosted: Tue Dec 25, 2007 5:05 am 
Beginner
Beginner

Joined: Fri Sep 28, 2007 9:50 pm
Posts: 34
Is it possible to have a “map” mapping for a many-to-many relationship in which a key maps to multiple values? That is, the value type would itself be a collection. It says in the documentation that “collections may not contain other collections” which seems to preclude this. Even so, might there be some way I could map a ternary association to such an interface (without creating additional database tables)?

The solution I am using for the time-being, is to create a new entity which maps to what would otherwise be the association table. The main entity then contains a one-to-many set mapping to the new entity:

Code:
<joined-subclass name="ParentClass">
   …
   <set name="BinaryRelations" inverse="true" cascade="all-delete-orphan">
      <key column="ParentID"/>
      <one-to-many class="BinaryRelation"/>
   </set>
</joined-subclass>
   
<class name="BinaryRelation">
   <id name="ID"><generator class="native"/></id>
   <many-to-one name="Parent" column="ParentID" class="ParentClass" not-null="true"/>
   <many-to-one name="Left" not-null="true"/>
   <many-to-one name="Right" not-null="true"/>
</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.