-->
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.  [ 2 posts ] 
Author Message
 Post subject: Pb mapping FK part of a composite id
PostPosted: Tue Dec 02, 2008 9:39 am 
Beginner
Beginner

Joined: Thu Jun 30, 2005 1:04 pm
Posts: 26
Hibernate version: 3.2.4

Name and version of the database you are using:Oracle 10

The generated SQL (show_sql=true):

I have a foreign key that is a part of a primary key.
This work fine in xml mapping, but i can't find a solution with Hibernate Annotations.
This is an exemple with hbm.xml files
Mapping documents:
Code:
   <class name="com.test.FooHbm">
      <composite-id name="id" class="com.test.FooId">
         <key-property name="num" type="integer"></key-property>
         <key-property name="code" type="integer"></key-property>
      </composite-id>
      <bag name="bars" inverse="true">
         <key column="NUMFK" property-ref="id.num"></key>
         <one-to-many class="com.test.BarHbm" />
      </bag>

   </class>
   <class name="com.test.BarHbm">
      <id name="id" type="integer" />
      <many-to-one name="foo" column="NUMFK" property-ref="id.num"
         class="com.test.FooHbm">
      </many-to-one>
   </class>


I have tried the same mapping with annotations with :
@ManyToOne
@JoinColumn(name = "FOO_NUM", referencedColumnName = "id.num")
Foo foo;
But i have the error message : "A Foreign key refering com.test.Foo from com.test.Bar has the wrong number of column. should be 2"

I have even tried to generate annoted files from hbm.xml, but the generated code have the same problem.

Do you have any idea ?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 5:07 am 
Beginner
Beginner

Joined: Thu Jun 30, 2005 1:04 pm
Posts: 26
Nobody cen help me ?


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.