Hi all,
i use an Oracle 8 & 9 Database.
I generated the mappings with middlegen and the code with hbm2java.
There is a table 'Antrag' which has a composite foreign key (LBID, ZUSTSB) to table 'Mitarb' with primary key (LBID,MITARBID).
When I run a simple test with table 'mitarb' I get the following Exception:
Code:
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception building SessionFactory: Foreign key (ANTRAG [LBID,ZUSTSB])) must have same number of columns as the referenced primary key (MITARB [MITARBID])
In the mapping for 'Mitarb' I found the composite primary key not correctly generated:
Code:
<composite-id name="comp_id" class="de.nrw.brd.osip.lvn.db.hibernate.MitarbPK">
<key-property
name="mitarbid"
column="MITARBID"
type="java.math.BigDecimal"
length="22"
/>
</composite-id>
I tried to generate the mapping without the referencing table 'ANTRAG ' and all was well:
Code:
<composite-id name="comp_id" class="de.nrw.brd.osip.lvn.db.hibernate.MitarbPK">
<key-property
name="mitarbid"
column="MITARBID"
type="java.math.BigDecimal"
length="22"
/>
<key-property
name="lbid"
column="LBID"
type="java.math.BigDecimal"
length="22"
/>
</composite-id>
Hibernate 2.1.2
middlegen-2.0-vo.jar
middlegen-hibernate-plugin-2.0-vo.jar
Can somone give me kick what's running wrong?[/code]