9 Replies Latest reply on Jan 31, 2005 8:23 PM by graysonpierce

    jboss-5.0.0alpha composite keys

    graysonpierce

      Hello,

      I'm having trouble with composite keys. I'm trying the composite key example in the with @EmbeddedId and it deploys just fine but when you do ant run I get the following:

       [java] log4j:WARN No appenders could be found for logger (org.jboss.remotin
      g.Client).
       [java] log4j:WARN Please initialize the log4j system properly.
       [java] Exception in thread "main" javax.transaction.TransactionRolledbackEx
      ception: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=110
      6337186340IT/14, BranchQual=, localId=14] status=STATUS_NO_TRANSACTION; - nested
       throwable: (org.hibernate.exception.ConstraintViolationException: Could not exe
      cute JDBC batch update)
       [java] at org.jboss.aspects.tx.TxSupport.endTransaction(TxSupport.java:
      220)
       [java] at org.jboss.aspects.tx.TxSupport.invokeInOurTx(TxSupport.java:1
      53)
       [java] at org.jboss.aspects.tx.TxSupport$Required.serverInvoke(TxSuppor
      t.java:438)
       [java] at org.jboss.aspects.tx.TxInterceptor.internalInvoke(TxIntercept
      or.java:112)
       [java] at org.jboss.aspects.tx.TxInterceptor.invoke(TxInterceptor.java:
      60)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInv
      ocation.java:66)
       [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropag
      ationInterceptor.java:62)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInv
      ocation.java:66)
       [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(
      StatelessInstanceInterceptor.java:36)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInv
      ocation.java:66)
       [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(A
      uthenticationInterceptor.java:77)
       [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInv
      ocation.java:66)
       [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(Sta
      telessContainer.java:148)
       [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:102)
       [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invok
      e(AOPRemotingInvocationHandler.java:74)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:29
      3)
       [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:16
      9)
       [java] at org.jboss.remoting.transport.socket.ServerThread.processInvoc
      ation(ServerThread.java:255)
       [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(Server
      Thread.java:304)
       [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerTh
      read.java:147)
       [java] Java Result: 1
      


        • 1. Re: jboss-5.0.0alpha composite keys
          bill.burke

          You're using latest CVS correct?

          I haven't gone through the tutorials yet to see if they are fixed or not.

          There is also an example of composite keys under:

          ejb3/src/test/org/jboss/ejb3/test/composite that is running well.

          • 2. Re: jboss-5.0.0alpha composite keys
            graysonpierce

            Bill,

            Correct, I'm using the latest from CVS. That example seems to be identical to the one I was using under

            jboss-head\ejb3\docs\tutorial\composite

            Also if I use my own code I get a different TransactionRolledbackException

            "org.hibernate.HibernateException: identifier of an instance of Symbol altered from SymbolPK@61 to null"

            And all I need to do is a read-only operation.

            • 3. Re: jboss-5.0.0alpha composite keys
              bill.burke

              That error looks like you forgot to implement equals and hashcode.

              • 4. Re: jboss-5.0.0alpha composite keys
                graysonpierce

                Bill,

                Thanks for the quick response. I do have the hashcode method (and this same code was working under 4.0 all I'm doing is changing from Dependent to Embedded). Has how you need to emplement hashcode changed for 5.0 alpha?

                public int hashCode() {
                
                return int1.hashCode() + int2.hashCode();
                 }
                
                 public boolean equals(Object obj) {
                 if (obj == this)
                 return true;
                 if (!(obj instanceof SymbolPK))
                 return false;
                 if (obj == null)
                 return false;
                 SymbolPK pk = (SymbolPK) obj;
                 return pk.int1 == int1 && pk.int2 == int2;
                 }
                }
                



                • 5. Re: jboss-5.0.0alpha composite keys
                  bill.burke

                  No, there's probably some bugs still in HB3 or the way I'm mapping metadata. You said you can reproduce the problem with the tutorial? I'm done for the weekend and I'll check it out next week. I'm looking to do another EJB3 release next week.

                  In the meantime, maybe the new HB query parser is the problem. Try removing this line from the hibernate.properties files:

                  hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory


                  Otherwise, I'll have to look into it next week.

                  Bill

                  • 6. Re: jboss-5.0.0alpha composite keys
                    graysonpierce

                    I tried removing

                    hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory

                    from the properties file but it doesn't seem to change the outcome.

                    • 7. Re: jboss-5.0.0alpha composite keys
                      graysonpierce

                      Bill,

                      I have a modified example that produces the error in questions. Please let me know if you need this but it would be VERY nice if it was fixed by the 1/31 build.

                      2005-01-26 16:57:24,410 INFO [STDOUT] javax.transaction.TransactionRolledbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=1106611033118IT/17, BranchQual=, localId=17] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.HibernateException: identifier of an instance of org.jboss.tutorial.composite.bean.Customer altered from org.jboss.tutorial.composite.bean.CustomerPK@75675174 to null)

                      • 8. Re: jboss-5.0.0alpha composite keys
                        bill.burke

                        please log a bug on jira.jboss.com under the ejb3 project with your attachment.

                        • 9. Re: jboss-5.0.0alpha composite keys
                          graysonpierce

                          In regards to this same issue I had filed a different case using the
                          @Dependent syntax

                          EJBTHREE-39 Composite Key field in JoinColumn causes Repeated column in mapping

                          That was closed (I believe by Bill) with the status of done. How could I access a build that fixed the composite key problem using either syntax?