Hibernate version: 2.1.8
Hello All,
I have a server and client database. The server contains the root of my object heirarchy. (A Sample and a Household)
It is passed to the client where the child objects (People and Trips) are attached and persisted into a client database.
Everything works fine for building and persisting the objects in the client database.
However, when I send the object heirarchy back to the server (and reattach to the server database) none of the collection keys/indices are written into the tables. All the other information (entity properties, many-to-one reference) are written properly.
There are no errors or exceptions on the update on the server. I've checked and the keys are correctly written on the client database.
The heirachy is Household has a list of People and each Person has list of Trips.
I have cascade="all-delete-orphan" set for all the lists
Each entity in the heirarchy has a composite ID.
Can anyone provide some hints as to whay this might be happening?
I use a session.saveOrUpdate (Household) to reattach the heirarchy. My custom interceptor (not really relevant to this issue) determines whether an insert or upate is required for each Entity.
Thanks in advance for any help you can provide.
Mapping files for the first level are:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="Household"
table="household"
dynamic-update="true"
dynamic-insert="true"
select-before-update="false"
optimistic-lock="version"
>
<composite-id
name="ID"
class="SampleCompositeID"
>
<key-property
name="sample"
type="java.lang.Long"
column="sampleid"
/>
<key-property
name="entityID"
type="java.lang.Long"
column="id"
/>
</composite-id>
<property
name="addressChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="addressChanged"
/>
<property
name="dwellingTypeChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="dwellingTypeChanged"
/>
<property
name="movedFlagChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="movedFlagChanged"
/>
<property
name="mailingReceivedChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="mailingReceivedChanged"
/>
<property
name="phoneNumberChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="phoneNumberChanged"
/>
<property
name="numberOfPeopleChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="numberOfPeopleChanged"
/>
<property
name="numberOfVehiclesChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="numberOfVehiclesChanged"
/>
<property
name="respondentNumberOfPeople"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="respondentNumberOfPeople"
/>
<property
name="phoneNumber"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="phoneNumber"
/>
<property
name="dwellingType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="dwellingType"
/>
<property
name="movedFlag"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="movedFlag"
/>
<property
name="mailingReceived"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="mailingReceived"
/>
<property
name="numberOfPeople"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="numberOfPeople"
/>
<list
name="personList"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
>
<key
>
<column
name="fk_householdid"
/>
<column
name="fk_householdsampleid"
/>
</key>
<index
column="fk_household_index"
/>
<one-to-many
class="Person"
/>
</list>
<property
name="numberOfVehicles"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="numberOfVehicles"
/>
<property
name="persistedOnServer"
type="boolean"
update="true"
insert="true"
access="property"
column="persistedOnServer"
/>
<property
name="persistedOnClient"
type="boolean"
update="true"
insert="true"
access="property"
column="persistedOnClient"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Household.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="Person"
table="person"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<composite-id
name="ID"
class="SampleCompositeID"
>
<key-property
name="sample"
type="java.lang.Long"
column="sampleid"
/>
<key-property
name="entityID"
type="java.lang.Long"
column="id"
/>
</composite-id>
<property
name="workLocationType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="workLocationType"
/>
<property
name="initialOriginLocationType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="initialOriginLocationType"
/>
<property
name="schoolLocationType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="schoolLocationType"
/>
<property
name="transitPassType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="transitPassType"
/>
<property
name="transitPass"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="transitPass"
/>
<property
name="transitPassChanged"
type="boolean"
update="true"
insert="true"
access="property"
column="transitPassChanged"
/>
<many-to-one
name="initialOrigin"
class="LocationDataWrapper"
cascade="all"
outer-join="auto"
update="true"
insert="true"
access="property"
>
<column
name="fk_originid"
/>
<column
name="fk_originsampleid"
/>
</many-to-one>
<property
name="initialOriginPurpose"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="initialOriginPurpose"
/>
<property
name="anyTripStatus"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="anyTripStatus"
/>
<property
name="label"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="label"
/>
<property
name="age"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
column="age"
/>
<property
name="genderType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="genderType"
/>
<property
name="licenseType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="licenseType"
/>
<property
name="employmentType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="employmentType"
/>
<property
name="occupationType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="occupationType"
/>
<property
name="studentType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="studentType"
/>
<list
name="tripList"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
>
<key
>
<column
name="fk_personid"
/>
<column
name="fk_personsampleid"
/>
</key>
<index
column="fk_person_index"
/>
<one-to-many
class="Trip"
/>
</list>
<property
name="persistedOnServer"
type="boolean"
update="true"
insert="true"
access="property"
column="persistedOnServer"
/>
<property
name="persistedOnClient"
type="boolean"
update="true"
insert="true"
access="property"
column="persistedOnClient"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Person.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>