[jboss-user] [EJB 3.0] - Re: Detached entity passed to persist

jactor do-not-reply at jboss.com
Fri Sep 22 08:23:45 EDT 2006


Please help me this so I can avoid the big head ache...

After a variety of debugging, this is the case:


  |         ...
  |         B b = a.getB();
  |         long id = saveOrUpdate(b); // Autoboxing. Originally an instance of Long
  |         entityManager.flush();
  |         b.setId(id);  // Autoboxing. Originally an instance of Long
  |         ...
  |  

I discovered that the memory referance of b.getId() was put to null when I flushed the entity manager. Before the flushing I had done some logging, but it was not valid anymore.

However; after flushing, persisting/merging A, and logging that b.getId() is  still a valid value, I still get the same exception:


  | javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: a.package.B
  | 

Is there some sort of configuration that I did not do? I thought that the merge method would check that the id of the entity was valid.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973540#3973540

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973540



More information about the jboss-user mailing list