aspose file tools
The moose likes Object Relational Mapping and the fly likes IllegalArgumentException: cannot remove/save a detached entity Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "IllegalArgumentException: cannot remove/save a detached entity" Watch "IllegalArgumentException: cannot remove/save a detached entity" New topic
Author

IllegalArgumentException: cannot remove/save a detached entity

Prashaant Sharma
Greenhorn

Joined: May 10, 2010
Posts: 1
Hi,

I have 3 entities with relationships shown below.

Entity: MyA


Entity: MyB


Entity: MyC


When removing already persisted MyA entity using below code, I am getting "java.lang.IllegalArgumentException: Removing a detached instance MyA" exception


Any help or pointers would be really helpful.
Thanks in advance
Tejas Morabia
Greenhorn

Joined: Mar 06, 2010
Posts: 7
A transfer object are usually detached. And detached object cannot be removed.
So i will suggest try to use merge before removing.
Try something like this


I hope this helps.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: IllegalArgumentException: cannot remove/save a detached entity
 
Similar Threads
JPA self refrencing relationship problem...HELP Needed
using 2 @OnetoMany annoations in one Entity Class
Problem with persisting entities because they become detached
JPA - need help with query
help me with mapping