• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cascade effects of EntityManager.remove()  RSS feed

Chandrasekhar Elindram
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is it possible to configure JPA Entity(using toplink) in such a way that it will throw an exception when I call entitymanager.remove() on an Entity which has child Entities associated to it.
I tried setting {cascade = CascadeType.Persist, CascadeType.Merge}, assuming that JPA will throw an error if it has to cascade the delete to child Entities. However, that is not the case, all the associated child entities are getting deleted, when I delete the parent.
At present, I'm checking the existence of associated entities after I get the actual Entity after calling entitymanager.find().

Is there any simpler option to control the delete operations?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!