The moose likes Object Relational Mapping and the fly likes Cascade Deletion Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Cascade Deletion" Watch "Cascade Deletion" New topic
Author

Cascade Deletion

Marco Barenkamp
Ranch Hand

Joined: Aug 27, 2001
Posts: 94
Hello,

To simplify the situation, I will construct a simple example:
Consider, I have a Person that has addresses (bi-directional)



The problem is:
When I update an existing address or when I create a new address, I simply use the

method and everythink works as expected.
But when I delete an address the deletion is not detected by the EntityManager,
beause I cannot see any SQL statements when I call

Is this the intended bahaviour? I was expecting the address to be removed when merging the appropriate person.

Any comments?
I am using Sun App Server 9 (TopLink) for this example.


Marco Barenkamp<br />_ _ _ _ _ ________________________ _ _ _ _ _ <br />L M I N T E R N E T S E R V I C E S AG<br /> <br />Head of Software Development<br /> <br /> <br />BEA Certified Enterprise Developer<br />Sun Certified Programmer for the Java2 Platform<br />Sun Certified Web Component Developer for the Java2 Platform<br />Sun Certified Developer for the Java 2 Platform <br />Sun Certified Business Component Developer for the Java 2 Platform <br />Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition<br /> <br />LMIS AG
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

Merging is for reattaching detached objects. Why aren't you calling persist to actually persist the change/deletion.

It depends, and it is explained in the Java Persistence with Hibernate book and also on the Hibernate website documentation page.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
IntelliJ Java IDE
 
subject: Cascade Deletion
 
Threads others viewed
EJB3/JPA @OneToOne
Foreign key value null if nullable true in @OneToMany assoc
EJB 3: Multiple (different) relations between two entities?
NonUniqueObjectException
EJB QL complexity and query time
IntelliJ Java IDE