-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Composite Foreign Key referencing non-primary
PostPosted: Wed Dec 31, 2008 9:01 am 
Newbie

Joined: Thu Jan 04, 2007 6:51 pm
Posts: 6
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"/>



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.