I have a problem when using the table-per-subclass mapping strategy. I have a class Parent and a class Child. The Child class is a subclass of Parent. In the Parent's mapping file, Child is defined as a joined-subclass. There is no other relationship defined between the Parent and Child.
There is a case in my application that a Parent record will be created first, then I need to create the corresponding Child in a different time. The problem I have is when I call session.save(aChildInstance), Hibernate tries to insert both records (into the two tables) and blows up because Parent already has a record with the pk. When I call session.update(aChildInstance), Hibernate tries to update both records and blows up because the Child is not in the database yet. The behavior of saveOrUpdate is the same as update.
Any help is greatly appreciated!
Weiguo
|