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