Ok, here's what I'm seeing, as simple as I can:
I have a ProfileObject.class which is linked by primary key "id" to a ProfileQuestion.class having primary key "qid" via an intermediate class ProfileProperty.class (Fields "pid" and "qid"). The three classes persist correctly to a Profiles table, Profile_Properties table and Profile_Questions table (mapping documents below).
The relationship is represented by a "Set" in the ProfileObject.class.
I can create a new profile in the Profiles table, and then add properties (objects to the Set) which cause an id and qid to be written correctly to the ProfileProperties table (the ProfileQuestions table already exists). When I perform a "get" of a profile, a ProfileProperty object looks like this:
"NULL NULL questionid questiontype questiontext"
The two nulls are supposed to be id and qid from the ProfileProperties object, which do indeed exist. The next three fields are correctly obtained from the Profile_Questions table.
The nulls are causing havoc when I use "contains" on the Set, even though I take it into account in my "Hashcode" implementation.
I suspect a mapping issue, so here are the mapping documents:
Code:
<!-- ProfileObject.hbm.xml -->
<class
name="gov.alaska.ezdoc.ProfileObject"
table="profiles"
dynamic-update="false"
dynamic-insert="false">
<id
name="id"
column="id"
type="java.lang.String">
<generator class="assigned">
</generator>
</id>
<set name="propertyList" table="profile_properties" lazy="false">
<key column="pid"/>
<composite-element class="gov.alaska.ezdoc.ProfileProperty">
<many-to-one name="profileQuestion" class="gov.alaska.ezdoc.ProfileQuestion" column="qid"/>
</composite-element>
</set>
</class>
<!-- ProfileProperty.hbm.xml -->
<class
name="gov.alaska.ezdoc.ProfileProperty"
table="profile_properties"
dynamic-update="false"
dynamic-insert="false">
<!-- the qid field is a foreign key to the Profile_Questions table -->
<id
name="qid"
column="qid"
type="java.lang.String">
<generator class="assigned">
</generator>
</id>
<!-- the pid field is a foreign key to the Profiles table id field -->
<property
name="pid"
type="java.lang.String"
update="true"
insert="true"
column="pid"/>
</class>
<!-- ProfileQuestion.hbm.xml -->
<class
name="gov.alaska.ezdoc.ProfileQuestion"
table="profile_questions"
dynamic-update="false"
dynamic-insert="false">
<id
name="qid"
column="qid"
type="java.lang.String">
<generator class="assigned">
</generator>
</id>
<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="type"/>
<property
name="question"
type="java.lang.String"
update="true"
insert="true"
column="question"/>
</class>
Ideas?
--Paul