Joined: Thu Jun 22, 2006 12:22 pm Posts: 1 Location: Wausau, WI
|
Hi,
I'm having trouble setting up a mapping file and would appreciate any help. Here is my database setup:
Table A
Table B - Joined to A - one-to-one
Table C - Joined to A - one-to-one
All three tables have database generated primary keys.
Tables B & C have a foreign key that is the primary key of A.
When I insert into A I also need to insert into B & C. My code inserts into A fine, however I get a cannot insert null exception from the database for B & C because the foreign key to table A isn't populated. How do I configure Hibernate to populate the foreign key property on the objects for B & C?
Thank you!
Here are my mapping files:
<hibernate-mapping>
<class name="com.fiservhealth.atf.ft.dao.Aos0034t" table="A">
<id name="assgnTransNbr" column="ASSGN_TRANS_NBR" type="int">
<generator class="native" />
</id>
<property name="transStatus" column="TRANS_STATUS" />
<property name="transFormTypeCd" column="TRANS_FORM_TYPE_CD" />
<property name="transRecCntl" column="TRANS_REC_CNTL" />
<property name="transCd" column="TRANS_CD" />
<property name="transCreateDt" type="timestamp" column="TRANS_CREATE_DT" />
<property name="transUserId" column="TRANS_USER_ID" />
<property name="transUserNm" column="TRANS_USER_NM" />
<property name="transUserTypeCd" column="TRANS_USER_TYPE_CD" />
<property name="transUpdateDt" column="TRANS_UPDATE_DT" />
<property name="transUpdateUserId" column="TRANS_UPDATE_USER_ID" />
<property name="transUpdateUserNm" column="TRANS_UPDATE_USER_NM" />
<property name="transProcdInd" column="TRANS_PROCD_IND" />
<property name="transProcdDt" type="timestamp" column="TRANS_PROCD_DT" />
<property name="transLastPageNbr" column="TRANS_LAST_PAGE_NBR" />
<property name="transProcdSuccessInd" column="TRANS_PROCD_SUCCESS_IND" />
<one-to-one name="atf0006t" class="com.fiservhealth.atf.ft.dao.Atf0006t" foreign-key="assgnTransNbr" cascade="all" property-ref="assgnTransNbr" />
<one-to-one name="atf0022t" class="com.fiservhealth.atf.ft.dao.Atf0022t" foreign-key="assgnTransNbr" cascade="all" property-ref="assgnTransNbr" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.fiservhealth.atf.ft.dao.Atf0006t" table="B">
<id name="assgnMembTransNbr" column="ASSGN_MEMB_TRANS_NBR" type="int">
<generator class="native" />
</id>
<property name="assgnTransNbr" type="int" column="ASSGN_TRANS_NBR" />
<property name="empFirstNameTxt" column="EMP_FIRST_NAME_TXT" />
<property name="empLastNameTxt" column="EMP_LAST_NAME_TXT" />
<property name="subscriberId" column="SUBSCRIBER_ID" />
<property name="grpNbr" column="GRP_NBR" />
<property name="socSecNbr" column="SOC_SEC_NBR" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.fiservhealth.atf.ft.dao.Atf0022t" table="C">
<id name="assgnFlexTransParkNbr" column="ASSGN_FLEX_TRANS_PARK_NBR" type="int">
<generator class="native" />
</id>
<property name="assgnTransNbr" type="int" column="ASSGN_TRANS_NBR" />
<property name="createDt" type="timestamp" column="CREATE_DT" />
<property name="flexTransAmt" column="FLEX_TRANS_AMT" />
<property name="flexTransPrcsInd" column="FLEX_TRANS_PRCS_IND" />
<property name="empContrAmt" column="EMP_CONTR_AMT" />
</class>
</hibernate-mapping>
|
|