[jboss-dev-forums] [EJB3 Development] - EntityManager.remove() throws java.lang.IllegalArgumentException: Removing a detached instance ?
Joseph Hwang
do-not-reply at jboss.com
Sun Mar 13 01:41:12 EST 2011
Joseph Hwang [http://community.jboss.org/people/aupres] created the discussion
"EntityManager.remove() throws java.lang.IllegalArgumentException: Removing a detached instance ?"
To view the discussion, visit: http://community.jboss.org/message/592898#592898
--------------------------------------------------------------
@Stateless
public class LoginSession implements ILoginSession {
@PersistenceContext(unitName="MyHome")
EntityManager em;
....
public Object loginFunc(Class clazz, Object primaryKey) {
// TODO Auto-generated method stub
return em.find(clazz, primaryKey);
}
public Object removeFunc(Serializable entity) {
// TODO Auto-generated method stub
em.remove(entity);
return entity;
}
.....
}
bean codes are like above.
in JSP file
ILoginSession login = ctx.lookup(LoginSession/remote);
Members erase = (Members)login.loginFunc(Members.class,"father");
out.println(erase.toString()); // It works to this lines
login.removeFunc(erase); // but this line thows Exception
EntityManager.remove() fuction throws "java.lang.IllegalArgumentException: Removing a detached instance"
I need your advice..
Best Regards....^_^
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/592898#592898]
Start a new discussion in EJB3 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2030]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110313/be9b3dae/attachment.html
More information about the jboss-dev-forums
mailing list