-->
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: map one-to-many returning same object within list
PostPosted: Thu May 26, 2005 11:53 am 
Newbie

Joined: Wed Apr 20, 2005 5:05 pm
Posts: 12
Hello,
Right to it. Here is my mapping.
Code:
<class name="PartyItem" table="Party" lazy="false" discriminator-value="P" >   
       <id
         name="uniqueIdentifier"
         column="party_id"
         type="integer"
         unsaved-value="-1">
         <generator class="identity"/>
      </id>   
      
      <discriminator column="subclass" insert="false" type="character" />      
      
      <property name="name" column="name" type="java.lang.String" not-null="true" />       
      <property name="description" column="description" type="java.lang.String" not-null="true" />       
      <property name="created" column="createdate" type="timestamp" not-null="true" />   

       <map name="cmPartyPreferences" cascade="all" inverse="true" fetch="join" lazy="false" table="PartyPreference"
          outer-join="true" >
         <key column="party_id" />
         <map-key column="preferenceType_id" type="integer" />
         <one-to-many class="PartyPreference" />
      </map>....


the map in question is cmPartyPreferences...here is the PartyPreference (the one-to-many within the map) mapping....

Code:
<class name="PartyPreference" table="PartyPreference" dynamic-update="false" lazy="false">
       <id column="preferenceType_id" type="integer" name="uniqueIdentifier">
          <generator class="identity"/>
       </id>
       
       <many-to-one name="partyItem" column="party_id" class="PartyItem" />

      <property name="fieldString" column="preference_value_string" type="java.lang.String" />              
       <property name="fieldInt" column="preference_value_int" type="integer" />       
       <property name="fieldClob" column="preference_value_clob" type="java.lang.StringBuffer" />       
       <property name="fieldDate" column="preference_value_date" type="timestamp" />
      
       <join table="PreferenceType" inverse="false" optional="false">         
         <key>
              <column name="preferenceType_id"/>
          </key>      
          <property name="name" column="name" type="java.lang.String" not-null="true" />                
          <property name="fieldType" column="application_datatype_id" type="integer" not-null="true" />
      </join> 
   </class>


If I query on for one item, as in findPartyById...everything is great, the collections are perfect. When I get a list, as in findPartiesByType, the list i get back seems right but the map "cmPartyPreferences" for each party in the list is identical, they are in fact correct for the first object in the list, but the rest of the parties in the list have a reference to the same object.

What am i doing wrong? I honestly didn't notice this for some time as I assumed (first mistake) that my mappings were spot on and I never really looked at the actual content. Any help is greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 12:49 pm 
Newbie

Joined: Wed Apr 20, 2005 5:05 pm
Posts: 12
Fixed. In short, don't use legacy <join>. Just use many-to-one...


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.