-->
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.  [ 3 posts ] 
Author Message
 Post subject: many-to-any association inside a Map
PostPosted: Thu Jun 23, 2005 4:08 pm 
Newbie

Joined: Thu Jun 23, 2005 3:59 pm
Posts: 1
Location: Canada
After struggling for a long time trying to get a many-to-any mapping working inside a Map with implicit polymorphism (table-per-concrete-class) I've finally figured it out. I've seen a couple posts asking for an example of a working many-to-any association, since seeing an example could've saved me a lot of time I'm going to post mine here.

Code:
<hibernate-mapping>
   <class name="VariableContent"
      table="VARIABLE_CONTENT">

      <id name="id" type="int" column="ID">
         <meta attribute="scope-set">protected</meta>
         <generator class="native" />
      </id>

      <map name="contentMap">
         <key column="foreign_key" />      
         <index column="map_key" type="string" />
         <many-to-any id-type="int">
            <column name="class_name" />
            <column name="item_id" />
         </many-to-any>
      </map>
      
   </class>
</hibernate-mapping>


That's it! Enjoy ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 6:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, or use union-subclass and many-to-many in HB3


Top
 Profile  
 
 Post subject: Re: many-to-any association inside a Map
PostPosted: Fri Aug 19, 2005 5:08 am 
Newbie

Joined: Mon Oct 18, 2004 11:19 am
Posts: 8
hmlyons wrote:
After struggling for a long time trying to get a many-to-any mapping working inside a Map with implicit polymorphism (table-per-concrete-class) I've finally figured it out. I've seen a couple posts asking for an example of a working many-to-any association, since seeing an example could've saved me a lot of time I'm going to post mine here.

Code:
<hibernate-mapping>
   <class name="VariableContent"
      table="VARIABLE_CONTENT">

      <id name="id" type="int" column="ID">
         <meta attribute="scope-set">protected</meta>
         <generator class="native" />
      </id>

      <map name="contentMap">
         <key column="foreign_key" />      
         <index column="map_key" type="string" />
         <many-to-any id-type="int">
            <column name="class_name" />
            <column name="item_id" />
         </many-to-any>
      </map>
      
   </class>
</hibernate-mapping>


That's it! Enjoy ;)


Strange, thought name attr was needed with many-to-any tag


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