I saw the "Parent/child relationship" chapter and added cascade="all" in my mapping file. I am using a <one-to-many /> tag in ObjectA
I am not using <many-to-one... /> in the ObjectB
I get an error. When I try to create a new entry, it seems to be doing alright with the ObjectA. But it seems to be updating the ObjectB instead of inserting and then throws an exception.
Here is the debug log for Hibernate classes.
Code:
2004-01-27 14:54:55,373 DEBUG (SetTypeCodesCmd.java:433) - Setting TypeCode OID = 400001
2004-01-27 14:54:55,373 DEBUG (SetTypeCodesCmd.java:447) - Found TypeCodeText. Setting TypeCode OID = 400001
2004-01-27 14:54:55,393 DEBUG (EntityPersister.java:464) - Inserting entity: com.gtech.service.typecode.TypeCode#400001
2004-01-27 14:54:55,413 DEBUG (EntityPersister.java:366) - Dehydrating entity: com.gtech.service.typecode.TypeCode#400001
2004-01-27 14:54:55,453 DEBUG (EntityPersister.java:617) - Updating entity: com.gtech.service.typecode.TypeCodeText#com.gtech.service.typecode.TypeCodeText@6d9e6c[locale=en_US,typeCodeOid=400001]
2004-01-27 14:54:55,483 DEBUG (EntityPersister.java:366) - Dehydrating entity: com.gtech.service.typecode.TypeCodeText#com.gtech.service.typecode.TypeCodeText@6d9e6c[locale=en_US,typeCodeOid=400001]
Code:
<class name="com.gtech.service.typecode.TypeCode" table="MS_TYPE_CODE2">
<id column="TYPE_CODE_OID" name="id" type="java.lang.Long">
<generator class="assigned"/>
</id>
<property column="TYPE_CODE" length="5" name="typeCode" not-null="true" type="java.lang.Short"/>
<property column="APPL_VARIABLE" length="255" name="applVariable" type="java.lang.String"/>
<property column="PATH" length="255" name="path" not-null="true" type="java.lang.String"/>
<property column="SEQ_NUM" length="5" name="seqNum" not-null="true" type="java.lang.Short"/>
<property column="ACTIVE_FLAG" length="5" name="activeFlag" not-null="true" type="java.lang.Short"/>
<property column="MODIFIABLE_FLAG" length="5" name="modifiableFlag" not-null="true" type="java.lang.Short"/>
<property column="MODIFIED_DATETIME" length="29" name="modifiedDatetime" not-null="true" type="java.util.Date"/>
<property column="MODIFIER_ID" length="30" name="modifierId" not-null="true" type="java.lang.String"/>
<set name="typeCodeText" lazy="false" inverse="false" cascade="all">
<key column="TYPE_CODE_OID"/>
<one-to-many class="com.gtech.service.typecode.TypeCodeText"/>
</set>
</class>
<class name="com.gtech.service.typecode.TypeCodeText" table="MS_TYPE_CODE_TEXT2">
<composite-id>
<key-property column="LOCALE" length="30" name="locale" type="java.lang.String"/>
<key-property column="TYPE_CODE_OID" length="19" name="typeCodeOid" type="java.lang.Long"/>
</composite-id>
<property column="ABBR_DISPLAY_TEXT" length="60" name="abbrDisplayText" type="java.lang.String"/>
<property column="DISPLAY_TEXT" length="255" name="displayText" type="java.lang.String"/>
</class>