users@glassfish.java.net

Re: EJB3 CMP TOPLINK BUG

From: <glassfish_at_javadesktop.org>
Date: Mon, 26 Mar 2007 06:10:17 PST

This is not a bug. The issue you are experiencing is that the account object is detached in the remote case. You must be sending the account to a client and back to the SessionBean causing the account object to be serialized when using the remote interface.

After reviewing the JPA documentation and java docs you will see that passing a detached object (as stated in the exception) to the remote(Entity) method is not allowed. The object passed must be managed in the Persistence Context attached to the EntityManager.

You can keep your code as provided or alternatively update your destroy() method to look more like the original.

public void destroy(Account account) {
  Account managedAccount = em.find(Account.class, account.getId());
  //or
  //Account managedAccount = em.merge(account);
  em.remove(managedAccount);
}

--Gordon
[Message sent by forum member 'gyorke' (gyorke)]

http://forums.java.net/jive/thread.jspa?messageID=209842