Hi,
The mapping I created has a signle parent and a few children classes. I have the cascade option enabled for all operations. The cascade works fine for all the classes tied to it but in the case of the otheridentifiers class it does an update rather than a save when I attempt to save the consumers object.
For eg: For templates the sql it spits out is
Hibernate: insert into TEMPLATES (USER_ID, TEMPLATE_TYPE, CREATE_TIME, UPDATE_TIME, OPERATOR_ID, DESCRIPTION, OP_ACTION_CODE, TEMPLATE_VALUE, TEMPLATE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
but for Other identifers it does an update
update OTHER_IDENTIFIERS set USER_ID=?, VALID_DATE=?, EXPIRY_DATE=?, ISSUER_INFO=?, DESCRIPTION=? where ID=? and ID_TYPE=?
Here are the two mapping files that concern this issue
-----------------------------------------------------------------------------
<hibernate-mapping package="com.sivault.BusinessObjects">
<class
name="OtherIdentifiers"
table="OTHER_IDENTIFIERS"
>
<composite-id>
<key-property name="Id" column="ID" type="string"/>
<key-property name="IdType" column="ID_TYPE" type="string"/>
</composite-id>
<many-to-one name="IdSet" column="USER_ID" class="Consumers" outer-join="true"/>
<property
name="ValidDate"
column="VALID_DATE"
type="date"
not-null="false"
length="7"
/>
<property
name="ExpiryDate"
column="EXPIRY_DATE"
type="date"
not-null="false"
length="7"
/>
<property
name="IssuerInfo"
column="ISSUER_INFO"
type="string"
not-null="false"
length="64"
/>
<property
name="Description"
column="DESCRIPTION"
type="string"
not-null="false"
length="128"
/>
</class>
</hibernate-mapping>
------------------------------------------------------------------------------
and
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.sivault.BusinessObjects">
<class
name="Consumers"
table="CONSUMERS"
>
<id name="UserId" column="USER_ID" type="integer">
<generator class="increment"/>
</id>
<one-to-one name="Template" class="Templates" property-ref="User" cascade="all"/>
<set name="BankCardsSet" inverse="true" cascade="all">
<key column="USER_ID"/>
<one-to-many class="BankCards"/>
</set>
<set name="CreditCardSet" inverse="true" cascade="all">
<key column="USER_ID"/>
<one-to-many class="CreditCards"/>
</set>
<set name="OtherIdentifiersSet" inverse="true" cascade="all-delete-orphan">
<key column="USER_ID"/>
<one-to-many class="OtherIdentifiers"/>
</set>
<property
name="UserName"
column="USER_NAME"
type="string"
not-null="false"
length="32"
/>
<property
name="BirthDate"
column="BIRTH_DATE"
type="date"
not-null="false"
length="32"
/>
<property
name="ssn"
column="SSN"
type="string"
not-null="false"
length="32"
/>
<property
name="PrimaryPhoneNo"
column="PRIMARY_PNONE_NUMBER"
type="string"
not-null="false"
length="32"
/>
<property
name="SecondaryPhoneNo"
column="SECONDARY_PHONE_NUMBER"
type="string"
not-null="false"
length="32"
/>
<property
name="DriverLicense"
column="DRIVER_LICENSE"
type="string"
not-null="false"
length="32"
/>
<property
name="url"
column="URL"
type="string"
not-null="false"
length="32"
/>
<property
name="FaxNumber"
column="FAX_NUMBER"
type="string"
not-null="false"
length="32"
/>
</class>
</hibernate-mapping>
--------------------------------------------------------------------------------
|