Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EntityManager.remove() fuction throws java.lang.IllegalArgumentException

Joseph HwangMar 14 2011 — edited Mar 14 2011
@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 void removeFunc(Serializable entity) {
// TODO Auto-generated method stub
em.remove(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....^_^

Edited by: 변강쇠 on 2011. 3. 15 오전 9:24
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2011
Added on Mar 14 2011
1 comment
743 views