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.