The model I am working is of legacy type with foreign keys map to a non-primary unique keys. A particular relationship is of unidirectional and referencing a composite non-primary key. (I read in the forum that JPA annotation does not support this and hence using hibernate mapping)
Based on the example given in the section 'Composite foreign key referencing nonprimary keys' of the book 'Java Persistence with Hibernate', I created this mapping file.
During runtime, I am getting a error stating that the property-ref 'userPoType' (code pasted below) is not found.
Could anyone help me fix the error?
Thanks
The relationship is as given below
1. Attributes CATNBR, POTYPE of Table CSENTRYPOLICY reference
IBASEPOLICYTYPEID, SPOLICYPRINTTITLE of Table CSentryUserPolicyType
2. IBASEPOLICYTYPEID is a foreign key to iPolicyTypeID of Table CSentrySystemPolicyType
The mapping is as given below
Code:
<many-to-one name="policyType" class="CSentryUserPolicyType" property-ref="userPoType">
<column name="CATNBR"/>
<column name="POTYPE"/>
</many-to-one>
Where CSentryUserPolicyType has a foreign-key relation with CSentrySystemPolicyType
Code:
<properties name="userPoType" unique="true">
<property name="sPolicyPrintTitle" column="SPOLICYPRINTTITLE" type="java.lang.String"/>
<many-to-one name="basePolicyType" column="IBASEPOLICYTYPEID" class="CSentrySystemPolicyType"/>
</properties>
and the CSentrySystemPolicyType mapping file looks like this.
Code:
<class name="CSentrySystemPolicyType" table="CSENTRYSYSTEMPOLICYTYPE">
<id name="iPolicyTypeID" column="IPOLICYTYPEID"/>