Thanks for the reply.
I am using Hibernate 2.x and Spring 1.2.x
the problem is that it does not allow me to put cascade="all, delete-orphan"
It gives me the following exception:
nested exception is net.sf.hibernate.MappingException: invalid mapping - with nested exception: [org.xml.sax.SAXParseException: Attribute "cascade" with value "all,delete-orphan" must have a value from the list "none all save-update delete all-delete-orphan delete-orphan
If for the parent table mapping XML if inverse="false" and cascade="all" is given then it becomes a responsilibility of the parent to persist children as well and update any referential integrity constraints as well.
So hibernate fires 2 queries:
1. Insert query which inserts values into the parent table (ENDPOINT)
2. Update query on the child table updating the foreign key (ENDPOINT_ID)
However it does not fire the query for inserting values into the child table. Which is a little strange.
While adding the children to the Set contained in the parent object i am also setting the parent for each child that is getting added.
The option suggested by you - turning inverse="true" and cascade="all, delete-orphan"
|