4 Replies Latest reply on Feb 8, 2006 12:05 AM by Chris Hane

    Understanding Conversations

    Chris Hane Novice

      I've been picking through the Seam source code trying to understand how conversations are implemented.

      One question I am wrestling with understanding is how conversations with state saved on the client work. Looking through the code, I expected to see the re-created component re-associated with a transaction somewhere.

      Could someone point me to the place(s) where I could pick up the program flow for seeing how a conversation objects are re-attached to a transaction.

      Thanks in advance,
      Chris....

        • 1. Re: Understanding Conversations
          Gavin King Master

          I don't understand what you mean. Seam components are not transactional.

          Are you talking about entities in a Seam-managed persistence context?

          • 2. Re: Understanding Conversations
            Chris Hane Novice

            Sorry, yes I am talking about the Entities. To walk through on of the examples, I'm looking at the exampe/hibernate.../HotelBookingAction.java.

            A conversation is started when the find() method is called. I see that the hotels variable is set based on a call to the persistence engine (in this case it is the bookingDatabase).

            Then a view is returned displaying all of the hotels and the state is saved on the client. When a users selects a hotel it is saved in the hotel variable.

            In the bookHotel() method the booking object is created with references to a hotel and a user.

            When the confirm() method is called to save the booking, I am trying to understand some of the mechanics of how this works. Primarly, the persist(booking) takes the booking object and saves it to the database.

            In the booking object there is a reference to a Hotel. Somewhere during the http request that calls confirm(), doesn't the hotel reference have to be reassociated with the Session so that a TransientObjectException is not thrown.

            Hope this is clearer. I'm trying to understand how transactions work in Seam and how persistence is managed in a conversation.

            Chris....

            • 3. Re: Understanding Conversations
              Gavin King Master

              Seam-managed persistence contexts are extended pcs. As is the container-managed persistence context in the SFSB. Reassociation of a container-managed pc with a transaction always happens automatically when the the component is invoked.

              In the current releases of Hibernate (and the current spec revision), reassociation of a Seam-managed persistence context with a transaction happens automatically when the EM or Session is invoked. (Actually this is changing in the final draft of the spec.)

              I suggest you read what the EJB3 spec has to say about this stuff.

              • 4. Re: Understanding Conversations
                Chris Hane Novice

                Gavin,

                Thanks for responding and pointing me in the right direction. It has been a while since I looked at EJBs (actually 2.x timeframe). I can already tell it makes sense just reading section 5.6 (Persistent Contexts - in the persistence spec). I now have lots of reading/learning to do in my spare time...

                Thanks again,
                Chris....