Hi,
I am trying to create a one-to-many mapping between two of my classes, one in a view having a composite key and the other a normal table.
I am getting the following exception when the session factory is being created,
org.hibernate.MappingException: Foreign key (FKF327F4562EB74EE3:ACCOUNTS_CONTACTS_COLL_RPT [ACCOUNT_NO])) must have same number of columns as the referenced primary key (V_PYCIS_DWH_ACCT [INSTN_ID_N,INSTN_NM_C,TMPL_TYPE_LVL_1_C,TMPL_TYPE_LVL_2_C,TMPL_TYPE_LVL_3_C,DWS_ACCT_ID,CIBS_ACCT_NUM_N,QIMD_PORTF_NUM_C,CIBS_DISC_NM_C,CIBS_DISC_CODE_C,CIBS_SUBDISC_CODE_C,CIBS_SUBDISC_NM_C,CIBS_STRUC_CODE_C,QIMD_STRUC_CODE_C,IM_BRAND_CODE_C,ASAP_ACCT_NM_C,ASAP_ACCT_NUM_N])
Foreign key (FKF327F4562EB74EE3:ACCOUNTS_CONTACTS_COLL_RPT [ACCOUNT_NO])) must have same number of columns as the referenced primary key (V_PYCIS_DWH_ACCT [INSTN_ID_N,INSTN_NM_C,TMPL_TYPE_LVL_1_C,TMPL_TYPE_LVL_2_C,TMPL_TYPE_LVL_3_C,DWS_ACCT_ID,CIBS_ACCT_NUM_N,QIMD_PORTF_NUM_C,CIBS_DISC_NM_C,CIBS_DISC_CODE_C,CIBS_SUBDISC_CODE_C,CIBS_SUBDISC_NM_C,CIBS_STRUC_CODE_C,QIMD_STRUC_CODE_C,IM_BRAND_CODE_C,ASAP_ACCT_NM_C,ASAP_ACCT_NUM_N])
My mapping classes are defines as follows
VPycisDwhAcctId.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Sep 3, 2007 5:14:09 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="com.pyramis.pcr.vo.VPycisDwhAcct" table="V_PYCIS_DWH_ACCT">
<composite-id name="id" class="com.pyramis.pcr.vo.VPycisDwhAcctId">
<key-property name="instnIdN" type="long">
<column name="INSTN_ID_N" precision="12" scale="0" />
</key-property>
<key-property name="instnNmC" type="string">
<column name="INSTN_NM_C" />
</key-property>
<key-property name="tmplTypeLvl1C" type="string">
<column name="TMPL_TYPE_LVL_1_C" length="12" />
</key-property>
<key-property name="tmplTypeLvl2C" type="string">
<column name="TMPL_TYPE_LVL_2_C" length="12" />
</key-property>
<key-property name="tmplTypeLvl3C" type="string">
<column name="TMPL_TYPE_LVL_3_C" length="12" />
</key-property>
<key-property name="dwsAcctId" type="java.lang.Long">
<column name="DWS_ACCT_ID" precision="12" scale="0" />
</key-property>
<key-property name="cibsAcctNumN" type="big_decimal">
<column name="CIBS_ACCT_NUM_N" precision="22" scale="0" />
</key-property>
<key-property name="qimdPortfNumC" type="string">
<column name="QIMD_PORTF_NUM_C" length="12" />
</key-property>
<key-property name="cibsDiscNmC" type="string">
<column name="CIBS_DISC_NM_C" length="50" />
</key-property>
<key-property name="cibsDiscCodeC" type="string">
<column name="CIBS_DISC_CODE_C" length="5" />
</key-property>
<key-property name="cibsSubdiscCodeC" type="string">
<column name="CIBS_SUBDISC_CODE_C" length="5" />
</key-property>
<key-property name="cibsSubdiscNmC" type="string">
<column name="CIBS_SUBDISC_NM_C" length="50" />
</key-property>
<key-property name="cibsStrucCodeC" type="string">
<column name="CIBS_STRUC_CODE_C" length="5" />
</key-property>
<key-property name="qimdStrucCodeC" type="string">
<column name="QIMD_STRUC_CODE_C" length="5" />
</key-property>
<key-property name="imBrandCodeC" type="string">
<column name="IM_BRAND_CODE_C" length="4" />
</key-property>
<key-property name="asapAcctNmC" type="string">
<column name="ASAP_ACCT_NM_C" length="50" />
</key-property>
<key-property name="asapAcctNumN" type="java.lang.Long">
<column name="ASAP_ACCT_NUM_N" precision="15" scale="0" />
</key-property>
</composite-id>
<set name="comments">
<key column="ACCOUNT_NO" />
<one-to-many class="com.pyramis.pcr.vo.AccountsContactsCollRpt"/>
</set>
</class>
</hibernate-mapping>
AccountsContactsCollRpt.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Sep 3, 2007 5:18:19 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="com.pyramis.pcr.vo.AccountsContactsCollRpt" table="ACCOUNTS_CONTACTS_COLL_RPT" schema="REPORTS">
<composite-id name="id" class="com.pyramis.pcr.vo.AccountsContactsCollRptId">
<key-property name="accountNo" type="integer">
<column name="ACCOUNT_NO" precision="8" scale="0" />
</key-property>
<key-property name="personCode" type="integer">
<column name="PERSON_CODE" precision="8" scale="0" />
</key-property>
<key-property name="startDate" type="timestamp">
<column name="START_DATE" length="7" />
</key-property>
<key-property name="reportCode" type="string">
<column name="REPORT_CODE" length="8" />
</key-property>
</composite-id>
<property name="feedDate" type="timestamp">
<column name="FEED_DATE" length="7" not-null="true" />
</property>
<property name="endDate" type="timestamp">
<column name="END_DATE" length="7" not-null="true" />
</property>
<property name="frequencyCode" type="string">
<column name="FREQUENCY_CODE" length="5" />
</property>
<property name="frequencyName" type="string">
<column name="FREQUENCY_NAME" length="50" />
</property>
<property name="distrMethodCode" type="string">
<column name="DISTR_METHOD_CODE" length="5" />
</property>
<property name="distrMethodName" type="string">
<column name="DISTR_METHOD_NAME" length="50" />
</property>
<property name="reportName" type="string">
<column name="REPORT_NAME" length="50" />
</property>
<property name="ldrIdN" type="java.lang.Short">
<column name="LDR_ID_N" precision="4" scale="0" />
</property>
<property name="ldDtD" type="timestamp">
<column name="LD_DT_D" length="7" />
</property>
<property name="numOfCopies" type="java.lang.Long">
<column name="NUM_OF_COPIES" precision="10" scale="0" />
</property>
<property name="outputMediaCode" type="string">
<column name="OUTPUT_MEDIA_CODE" length="5" />
</property>
<property name="outputMediaName" type="string">
<column name="OUTPUT_MEDIA_NAME" length="50" />
</property>
<property name="bindingMethodCode" type="string">
<column name="BINDING_METHOD_CODE" length="5" />
</property>
<property name="bindingMethodName" type="string">
<column name="BINDING_METHOD_NAME" length="50" />
</property>
<property name="packetCode" type="string">
<column name="PACKET_CODE" length="14" />
</property>
<property name="packetName" type="string">
<column name="PACKET_NAME" length="250" />
</property>
<property name="accountReportComments" type="string">
<column name="ACCOUNT_REPORT_COMMENTS" length="1000" />
</property>
<property name="packetComments" type="string">
<column name="PACKET_COMMENTS" length="1000" />
</property>
</class>
</hibernate-mapping>
How can i achieve this??
Thanks ,
Rohit