LinHib wrote:
I am using the "table per subclass" strategy for the PARENT-to-CHILDA relation, and it works.
But I am not able to use the same for PARENT-to-CHILDB relation since the primary key of CHILDB is not the same as the primary key of the PARENT. The primary key of CHILDB is (PARENT_ID, SEQ_NUM), where as the primary key of the PARENT is PARENT_ID alone.
class Parent {
Long parentId;
}
class ChildB extends Parent {
Collection<ChildBElement>;
}
class ChildBElement {
Long seqNum;
...
}
I defined a joined-subclass for CHILDB with key as PARENT_ID. Added a bag for the collection, with key as the SEQ_NUM. Now hibernate tries to insert a record into CHILDB with only PARENT_ID, and fails since SEQ_NUM is not nullable:
Generated SQL: insert into CHILDB (PARENT_ID) values (?)
It doesn't insert SEQ_NUM and other values in the ChildBElement. What am I doing wrong?
Thanks, LinHib.
Cheak that you are cascading from bag.can you tell exactly what is the exception you are getting