KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have 1-N relationship (object has a list) and want remove one item from the list. What is the right way of removing item in the list with JPA? Do I have to first update the list and merge the owner and remove the item after (if I do not remove the item and just merge the owner, orphan will remain in DB, right)? In what sequence should be merge() and remove() called, does the order of remove() and merge() matter? Code sample: List<Item> items = owner.getItems(); Item itemToRemove = items.get(index); owner.remove(itemToRemove); em.merge(owner); em.remove(itemToRemove);
Tags (comma-separated)
Save Edits
Cancel