by johan 21 May 22:20
delete-orphan cascade style

Does Ebean provide delete-orphan cascade style like Hibernate does? If not:
- any chance to see that in a future release?
- what would be your recommendation to implement such a use case? (E.g. Order->OrderLineItem, if I remove an orderLineItem from the order and save the order I want it being deleted from the db).

Thanks,
Johan

23 May 10:06
by Rob

Good questions...

The issue of "delete-orphan" as I understand it is related to the issue that the deletion of entities in a oneToMany on a detached entity is not taken into account on EntityManager.merge().

http://forums.java.net/jive/thread.jspa?threadID=25245

Now that is my understanding but I could be wrong there... I believe this is going to be part of JPA 2.0 as well.

If I am right about what "delete-orphan" is... then you will notice that Ebean does not have this issue, in that it does not differentiate attached from detached.

So cascade all will work just fine for you.

In the case you mention, if you have cascade=CascadeType.ALL on the relationship from order to orderLineItem, then when you save the order the appropriate orderLineItem's will be deleted.

So, unless I have missed the point/issue there is no change required for Ebean and CascadeType.ALL is all you need.

Cheers, Rob.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse