yvijaykumar wrote:
Hi
You dont have a column called OID so obviously you mapping file is wrong and thatswhy it is throwing that error. Just try genearting the class file and xml file using MiddleGen Tool. It should give you a clear picture
Thanks
Thank you for your reply. I tried MiddleGen in the past two days and made it work for normal table with a primary key. But still I have problem as described below.
Table 1, userid is the primary key
Table 2, roleid is the primary key
Table 3, userid and roleid are both foreign keys and that all in this table
I tried to use MiddleGen to generate mapping files for the above three tables and found composite-id should be used. Then when I tried to generate the java code, it was complained that composite-id is not correct. In fact it shouldn't be empty. I wonder how to set up the composite-id correctly. Also I want to know in this case, is it necessary to include Table 1 and 2 for MiddleGen. Thanks.
X. Yang
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="sbdb.SbUserRole"
table="sb_user_roles"
>
<composite-id>
</composite-id>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
<!-- bi-directional many-to-one association to SbRole -->
<many-to-one
name="sbRole"
class="sbdb.SbRole"
not-null="true"
>
<column name="roleid" />
</many-to-one>
<!-- bi-directional many-to-one association to SbUser -->
<many-to-one
name="sbUser"
class="sbdb.SbUser"
not-null="true"
>
<column name="userid" />
</many-to-one>
</class>
</hibernate-mapping>