12 Replies Latest reply on Sep 28, 2005 10:33 AM by nusa

    About Transaction

    nusa

      Hi,

      In the example under noejb, I don't see any declaration of transaction, i.e. session.beginTransaction(), transaction.commit() , or transaction.rollback().

      Are they been replaced by @Begin and @End ?
      Is there any relationship between @Begin and session.beginTransaction() ?

      Do you have a plan to 'port' CaveatEmptor using Seam ?

      Thanks.

        • 1. Re: About Transaction

           

          "nusa" wrote:
          Hi,

          In the example under noejb, I don't see any declaration of transaction, i.e. session.beginTransaction(), transaction.commit() , or transaction.rollback().

          Are they been replaced by @Begin and @End ?
          Is there any relationship between @Begin and session.beginTransaction() ?

          Do you have a plan to 'port' CaveatEmptor using Seam ?

          Thanks.


          There are plans to port caveatemptor and produce more 'tomcat' friendly demos for immediate deployment.

          • 2. Re: About Transaction
            nusa

            Thanks for your reply Jacob.

            But what about my questions on @Begin and @End ?

            • 3. Re: About Transaction

               

              "nusa" wrote:
              Thanks for your reply Jacob.

              But what about my questions on @Begin and @End ?



              @Begin and @End are separate from User Transactions. @Begin and @End is the same as marking the begin and end of a Sub-Session scope (the way I look at it). So object that are conversation scoped, become part of the conversation that has begun, and at the time that @End is invoked, those conversation scoped objects will get cleaned up from the session.

              For transaction details:
              http://docs.jboss.com/seam/reference/en/html/configuration.html#d0e1597

              -- Jacob

              • 4. Re: About Transaction
                nusa

                One thing that I don't understand is why there is no beginTransaction(), commit(), or rollback() in RegisterAction.java or HotelBookingAction when calling the persist() method.

                Am I missing something ?

                • 5. Re: About Transaction
                  gavin.king

                  This example uses Seam-managed transactions (SeamExtendedManagedPersistencePhaseListener) so that one transaction spans UPDATE_MODEL_VALUES and INVOKE_APPLICATION, and a second spans RENDER_RESPONSE

                  • 6. Re: About Transaction
                    bran

                     

                    "gavin.king@jboss.com" wrote:
                    This example uses Seam-managed transactions (SeamExtendedManagedPersistencePhaseListener) so that one transaction spans UPDATE_MODEL_VALUES and INVOKE_APPLICATION, and a second spans RENDER_RESPONSE


                    hmm... the code shows that Seam does a begin/commit for each new request, regardless of the context, not giving programmers fine-control of transaction demarcation. What if I have a sesssion bean that takes PROPOGATION_NEVER transaction attribute, for example? I expected Seam would allow annotation based demarcation.



                    • 7. Re: About Transaction
                      gavin.king

                      If you need fine-grained declarative transactions, you should of course be using EJB components, not JavaBeans components. This is mentioned in the documentation.

                      Of course, fine-grained transactions are usually an exceptional case, not the common case.

                      So Seam supports both EJB declarative container-managed transactions and request-scoped Seam-managed transactions - which are a great implementation of the OpenSessionInView pattern - or a combination of both approaches.

                      • 8. Re: About Transaction
                        nusa

                        Gavin,

                        I would like to use Seam with Hibernate, not EJB3.
                        That means I have to use SeamExtendedManagedPersisteencePhaseListener. But this managed transactions only supports corse-grained transaction. If I want to use a fine-grained, I have to use EJB3.

                        Am I correct by saying, that if I want use a fine-grained transation, use EJB3, not Hibernate ?

                        • 9. Re: About Transaction
                          gavin.king

                          Well, actually, it's easily possible to use Hibernate inside the JBoss EJB3 container. JBoss EJB3 can inject a Session instead of an EntityManager.

                          • 10. Re: About Transaction
                            gavin.king

                            Or, you could use SessionFactory.getCurrentSession() in any EJB3 container, not just in JBoss EJB3.

                            • 11. Re: About Transaction
                              nusa

                               

                              "gavin.king@jboss.com" wrote:
                              Well, actually, it's easily possible to use Hibernate inside the JBoss EJB3 container. JBoss EJB3 can inject a Session instead of an EntityManager.


                              Gavin,

                              If you have a sample code, in your blog, that would be great :)

                              • 12. Re: About Transaction
                                nusa

                                 

                                "gavin.king@jboss.com" wrote:
                                Or, you could use SessionFactory.getCurrentSession() in any EJB3 container, not just in JBoss EJB3.



                                Gavin,

                                Again, if you have a sample code, in your blog, that would be great :)