-->
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: idbag and composite-element
PostPosted: Tue Jun 29, 2004 3:33 pm 
Beginner
Beginner

Joined: Mon Nov 10, 2003 7:09 pm
Posts: 28
Is it possible to map a many-to-many association that contains extra properties on the join table with an <idbag> and <composite-element>? This is on v2.1.4.

I've tried the mapping snippet below:
Code:
<class name="ClassA" table="class_a" proxy="ClassA">
  <id name="oid" column="oid" type="long" unsaved-value="0">
     <generator class="sequence">
          <param name="sequence">fooseq</param>
      </generator>
  </id>
  <property name="title" column="title" type="string"/>
  <idbag name="collectionB" table="join_table" lazy="true">
     <collection-id column="oid" type="long">
          <generator class="sequence">
               <param name="sequence">fooseq</param>
           </generator>
      </collection-id>
      <key column="this_class_oid"/>
      <composite-element class="ClassA$ClassX">
            <property name="propA" column="propa" type="string"/>
            <property name="propB" column="propb" type="string"/>
            <many-to-one name="classY" column="class_y_oid" class="ClassY" outer-join="true"/>
       </composite-element>
  </idbag>


I get the right type of object, the extra properties (propA, propB) are correct, the associated class (classY) is correct, but for some reason the id of every one of the join table objects is 0. What I mean is, calling getClassX().getOID() always returns 0 for each member of the collection classA.getCollectionB().

Is this type of mapping supported? Or should I just give up and make ClassX a full-blown domain object and map it with a standard many-to-one?

Thanks!


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.