emmanuel wrote:
1. yes, but assigned generator has drawbacks. basically detached objects use the saveOrUpdate() method. Read documentations on that subject
2. all-delete-orphan remove an object that has been unlinked to it's parent. delete will delete sub objects if the master object is deleted (session.delete())
3. Yes the not-null attribute is used
1. What do you mean by assigned generator? I am using generator-class="native" everywhere. And I also use saveOrUpdate() all the time. I think the issue is that Hibernate traverses the object graph in a certain order (depth-first) which lets it encounter unsaved objects when it doesn't expect it. Here is the exception I am getting:
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.ichg.capsela.domain.component.flow.ControlEdge.sinkVertex
This happens in the saveOrUpdate() of the edge, and the source vertex has already been saved, but the sink vertex still has the unsaved-value in the primary key.
By now I am convinced that this is a bug in the handling of detached objects.
2. I didn't use cascade="all-delete-orphan" because cascade="all" already breaks. Instead I implemented my own cascading logic, but that breaks because Hibernate tries to update a not-null field.
3. I had not-null="true" as my XDoclet tag and used the ant schemaexport to generate the database. But Hibernate still tried to set the field to null, even though I just called Session.delete() on the edge. We don't have this problem in a similar situation when we don't use detached objects.
I think I have done everything right and can consitently reproduce the problems, so my conclusion is that the problem is with Hibernate. I would be happy to give you my source so you can see for yourself (it is a small prototype with about 20 classes), just tell me if you want to do that.