Hi We have developed program using Joined Subclass feature of hibernate.
First Class:
--------------------------
class Person{
String id; // this is primary key
String name;
get & set methods for both the properties
}
Second class:
---------------------------
class Order extends Person{
String orderid, // this is primary key or Unique key
String ordername;
get & set methods for both the properties
}
Maping file:
----------------------------------------------------------------
<hibernate-mapping default-lazy="false" auto-import="false">
<class name="Person" dynamic-update="false" dynamic-insert="false">
<id name="id" type="String" column="Person_ID">
// Assigned key
</id>
<property name="name" type="string" />
<joined-subclass name="Order" table="Order" dynamic-update="false" dynamic-insert="false">
<key column="Order_ID"/>
<property name="orderid" type="string" not-null="true"/>
<property name="ordername" type="string"/>
</joined-subclass>
</class>
</hibernate-mapping>
-------------------------------------------------------------------------
My intention is :
1) First I inserted a record in a Person with his details, it is sucessfully inserted in DB.
2) When I am trying to insert the data for Order I am getting an error ( JDBC batch operation), I am setting the values for the following fileds
1. id=1 // inherited from parent class
2. Orderid=1;
3. Ordername="myorder";
Can you please suggest what is the wrong in this and solution for the same.
We are in middle of the project, your help is more appreciated.
Regards,
Srinivas
|