4 Replies Latest reply on Oct 15, 2008 1:28 PM by brachie

    Seam transactions

    robbins

      Hi,
      I am using Seam managed EntityManager. Seam begins and end transactions which con-incident with the web request. I was just wondering is it possible to have more than one transaction using this approach, within a web request/
      Thanks

        • 1. Re: Seam transactions
          mrossix

          I have the same problem.

          • 2. Re: Seam transactions
            brachie

            Hi,


            my approach would be to use manual flushmode for conversations and flush the changes manually to the DB whenever you want. So you can span one transaction over several requests.



            Alexander

            • 3. Re: Seam transactions
              mrossix

              Thanks Alexander for your replay.


              My problem is the opposite: two different transaction in the same method.
              Look at this:


              MyBusinessObj{


              public void persistMyEntity(){


              // 1. persist a log information in a db table


              // 2. persist myEntity


              }
              }


              I want to commit always the first information (also with the rollaback of the second).



              Marco

              • 4. Re: Seam transactions
                brachie

                @Marco: Maybe you can try something like this:



                MyBusinessObj{
                
                ...
                
                public void persistMyEntity(){ 
                
                Session session = sessionFactory.openSession();
                
                org.hibernate.Transaction tx1 = session.beginTransaction();  
                      // 1. persist a log information in a db table 
                tx1.commit();
                
                
                org.hibernate.Transaction tx2 = session.beginTransaction();  
                    // 2. persist myEntity 
                tx2.commit();
                
                session.close();
                
                }




                I have not tried something like this but maybe it works...


                Alexander