orphanRemoval on JPA relationships is very useful, and possibly misnamed. It doesn't handle orphan removal, but it handles removing deleted child entities meaning that in JPA 2.0 you can remove an object in a collection and then persist the parent and it will actually remove the deleted child entity from the database.
http://docs.oracle.com/javaee/6/api/javax/persistence/OneToMany.html#orphanRemoval
I think the name orphanRemoval is strange. It's a terrible analogy, but when you have a parent duck and its ducklings, if you remove a duckling (kill it) it doesn't become an orphan, it just becomes dead.
No comments:
Post a Comment