• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalArgumentException: Removing a detached instance

 
Roberto Lopez Lopez
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good evening!

I've an app that uses Hibernate 3.2 as ORM. I've a problem at the following code piece:



When the thread reaches the remove call, the following IllegalArgumentException is thrown:

18:08:00,278 ERROR [[action]] Servlet.service() para servlet action lanz� excepci�n
java.lang.IllegalArgumentException: Removing a detached instance es.encore.nollego.comun.to.SubcategoriaPrivadaTO#es.encore.nollego.comun.to.SubcategoriaPrivadaPK@b0d5f5
at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:47)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:86)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:52)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:766)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)
at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:245)
at es.encore.nollego.comun.dao.subcategoriaPrivada.SubcategoriaPrivadaDAO_HBM.remove(SubcategoriaPrivadaDAO_HBM.java:67)
at es.encore.nollego.comun.bo.subcategoriaPrivada.SubcategoriaPrivadaBO.remove(SubcategoriaPrivadaBO.java:42)
...


Has anybody why I get such an exception??? My SubcategoriaPrivadaTO entity is as follows:



Any help will be appreciated! Thanks in advance...
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A detached entity cannot be removed (you get the above exception if you try to do so), and Transfer Objects usually are detached (I don't see enough context to be 100% sure in your case). Merge it before removing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic