1 2 Previous Next 19 Replies Latest reply on Apr 13, 2012 5:32 AM by jaikiran pai Go to original post
      • 15. Re: Problem with transactions...
        Scott Marlow Master

        So doesn't work the transactions in jboss as 7??

         

        I don't understand your question. 

         

        Rolling back the creation of entity 'com.alteda.labanda.entidades.Socio' worked.  For the other two entities, there wasn't a database operation to rollback (other than detaching the loaded entities from the entity manager persistence context).  If the other two entities were created as part of the transaction, they would of been rolled back also.  You got the correct result.

        1 of 1 people found this helpful
        • 16. Re: Problem with transactions...
          Jaime Poch Newbie

          I think my non perfect knowledge of english has drived me into a misunderstanding in your previous reply.

           

          I thought you were telling me that I found a bug because the transaction didn't work. But now I read it again I understand that you are telling me why it doesn't work like I expected. Is it correct?

           

          Now, you say

           

          So, the two entities that didn't get rolled back, were aleady added to the database in an earlier JTA transaction.

           

          but when?

           

          All the operations are executed in the same method, so all of them should be in the same transaction, shouldn't them?

           

          Basically I do, in the same method:

           

          • Create the entity Socio
          • Create the entity Log
          • Call merge method of EntityManager for Socio
          • Call merge method of EntityManager for Log
          • Modify the entity PeticionAlta (is the parameter of the method)
          • Call merge method of EntityManager for PeticionAlta

           

          Can be the problem the use of the merge method? Should I use persist method? Now I'm a bit confused.

           

          Thanks

          • 17. Re: Problem with transactions...
            Scott Marlow Master
            I thought you were telling me that I found a bug because the transaction didn't work. But now I read it again I understand that you are telling me why it doesn't work like I expected. Is it correct?

            Yes, your understanding is correct.  It doesn't work like you expected.  From the TRACE output, I can see that only one of the entities is new and that no updates were made to the other entities.

             

            Can be the problem the use of the merge method? Should I use persist method? Now I'm a bit confused.

            Sure, try the persist method.  If you call the persist method with an entity that is already saved to the database, you should get a EntityExistsException error.  If it is a new entity, it should be rolled back when the transaction rolls back. 

            1 of 1 people found this helpful
            • 18. Re: Problem with transactions...
              Jaime Poch Newbie

              Scott you'll think I'm an idiot. The rollback falis in the entities because of their tables are myisam and not innodb.

               

              Thanks a lot.

              • 19. Re: Problem with transactions...
                jaikiran pai Master

                Jaime Poch wrote:

                 

                The rollback falis in the entities because of their tables are myisam and not innodb.

                 

                 

                I've seen a number of users run into this "issue" with MySQL due to table configuration. So you are not the only one to run into this. It's just that developers least expect the DB to be the place where a basic feature like transaction handling to go wrong.

                1 2 Previous Next