3 Replies Latest reply on Oct 20, 2005 6:39 PM by Emmanuel Bernard

    Error while deleting Entities (FetchType)

    Christoph Krammer Newbie

      Hi,

      I'm writing a role management tool, and I have Permission-Objects with associated roles, defined as follows:

      @Entity
      @Table(name="permission")
      public class PermissionEntityBean implements Serializable {
      ...
       @ManyToOne(fetch=FetchType.EAGER)
       @JoinColumn(name="role")
       public RoleEntityBean getRole() {
       return role;
       }
      ...
      }
      


      When I try to delete such an PermissionEntityBean with em.remove(), I get the following error message:

      12:40:15,671 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=tiger/149, BranchQual=, localId=149] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.ObjectDeletedException: deleted entity passed to persist: [de.altaica.rrm.PermissionEntityBean#<null>])
      


      When I change the FetchType to LAZY it just works fine. Can anybody give me a hint _WHY_ this is the case? What influence does the FetchType have on the process of deleting entities?

      Thanks in advance,
      Christoph

        • 1. Re: Error while deleting Entities (FetchType)
          Jens Elkner Apprentice

          I've seen this, when one uses entities with a @Version, and the appropriate value in the DB is null ...

          • 2. Re: Error while deleting Entities (FetchType)
            Alejandro Bernal Newbie

            Hello: I'm having the same problem trying to delete any record, I'm not sure if the problem is related with the database, I've tested postgres 7.4 and 8 but I keep receiving the same error.

            Any ideal will be appreciated:

            This is the stack:

            java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=athlon/16, BranchQual=, localId=16] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.ObjectDeletedException: deleted entity passed to persist: [com.corgil.db.Permisosadmins#<null>])
             org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:185)
             org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:167)
             org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:74)
             org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:195)
             org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
             org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:37)
             org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
             org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:88)
             $Proxy90.eliminarPermiso(Unknown Source)
             org.apache.jsp.lstAdministradores_jsp._jspService(org.apache.jsp.lstAdministradores_jsp:123)
             org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
             org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
             org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
             javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            
            


            Thanks

            • 3. Re: Error while deleting Entities (FetchType)
              Emmanuel Bernard Master

               

              "ckrammer" wrote:
              When I change the FetchType to LAZY it just works fine. Can anybody give me a hint _WHY_ this is the case? What influence does the FetchType have on the process of deleting entities?


              I can only guess but IMO you do not remove the object fromt the collection on the other side and you have cascade persist on it
              => the deleted object is repersistec by cascade.