Hibernate version: use Jboss403sp1 , should be hibernate-3.1rc2.
Just wonder what will effect a success cascade="all, delete-orphan" for a Set collection (detached).
1. Child class should implment hashcode and equals.
2. pass to Diffenrent VM.
3. Keep the ref of collection.
4. dereference from Child side
5. do not detached.
Problem: like a some other's topic in this form, I only can persistence new add Child in Set collection(in a detached parent), but not delete.
I pass through the detached object via different VM. And My test shows little funny for me.
Say parent class is "A" Child is "B" B did not implment hashcode and equals. GUI call no state session Bean.
1. create A and few B in remote GUI side. send to server to save.
2. Check if it is a Transient just save it and close session, then it become detached return to GUI.
3. GUI modif A'set then save again, sever get the detached A , then load A's old version(persisitent) by uid.
4. check those B has been deleted by compare Detached and persisitent Object. Use (A's Old version) remove and dereference those B. saveOrUpdate
5. (Why have to have it for delete) flush() session;
6. Use (A's Old version ) 's set.clear() then pop any thing in detached A to persisitent A saveOrUpdate();
if I didn't have 2-6, only have single saveOrUpdate, not delete.
if I didn't have 5 flush , not delete (why?)
if I didn't have 4,5 just do 6 not delete ( why?)
Can anyone help? Thank.
|