Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » OPEN - Disable delete an entity when is its linked in relationships
OPEN - Disable delete an entity when is its linked in relationships [message #1065038] Sun, 23 June 2013 18:52 Go to next message
Matias Comesaña is currently offline Matias Comesaña
Messages: 1
Registered: June 2013
Junior Member
Hi! First of all, thanks for reading this and try to help me! Lets supose that there is 2 entities e1 and e2 and e1 is linked to e2 in a ManyToMany relationship (e1 has a list of e2 kind). Is there a way to throw an exception when trying to remove e2 (since e2 is linked in the e1 list)?
Re: OPEN - Disable delete an entity when is its linked in relationships [message #1065396 is a reply to message #1065038] Tue, 25 June 2013 10:39 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Assuming you have a constraint defined in your join table, the database will throw an error when you try to delete e2 (after commit or flush).

If you want to check it in your app, then would be best to make it a bidirectional ManyToMany, then you can check the collection on remove.


James : Wiki : Book : Blog : Twitter
Previous Topic:entitymanager problem merge
Next Topic:JPA Mapping Multi-Rows with ElementCollection
Goto Forum:
  


Current Time: Thu Apr 17 03:43:52 EDT 2014

Powered by FUDForum. Page generated in 0.14279 seconds