3 Replies Latest reply on Mar 11, 2002 4:02 AM by Mac Rinehart

    transaction context problem

    Mac Rinehart Newbie

      Perhaps someone can shed some light on this problem for me. I'm assembling a little test application for CMP with compound primary keys. It performs the following operations:

      1. Get remoteHome on bean1
      2. Create remote object of bean1
      3. Get remoteHome on bean2 (different type of bean from bean1)
      4. Create remote object of bean2
      5. Update field of bean1 through bean1 remote interface
      6. Get updated attribute of bean1
      7. Update field of bean2 through bean2 remote interface - at this point I get a java.lang.IllegalStateException: removing bean lock and it has tx set!

      This is a test enviornment and there is only a single EJB client application running, so I'm not sure why I'm encountering a transaction locking problem on the second bean when I am the only client and the update to the second bean is the only operation subsequent to creating it. Any insights are greatly appriciated. Thanks,

      Mac

      PS I noted that when invoking CMP setters the persistent entity is deleted, and then inserted again, rather than just updating it. Why is that necessary?

        • 1. Re: transaction context problem
          David Jencks Master

          It's always polite to indicate which version of jboss you are using, even if you have just posted 10 other messages where you do say. Someone (me) might not have seen the others or might not remember what they said.

          In jboss 3, and possibly 2.2.x, this problem can occur if you have not properly implemented equals and/or hashcode on your pk object.

          Something very odd is going on if updates are deleting and recreating entities. Perhaps if you have this pk problem the container can't tell they are supposed to be the same entity.

          • 2. Re: transaction context problem
            Mac Rinehart Newbie

            Appologies on not reporting my version, I am working with the a build from this morning, with exception of the proxy.compiler package which has given me all kinds of other problems. That is from prior to the 3/7 update. I will investigate your recommendations. Thanks! :)

            • 3. Re: transaction context problem
              Mac Rinehart Newbie

              David, you are so money! Right on the mark with that advice. I identified one primary key problem right away and corrected it. But the other...that was a doosey. I misspelled one of the words in the class name and decided to rename it. But both my compiler and I missed three occurrences of the original spelling in the source code, all the in .equals method. All because of a change to a single character! :( Doh!

              Corrected that and the delete and insert issue went away. Thanks,

              Mac