2 Replies Latest reply on Jun 13, 2007 3:40 AM by Torsten Fink

    How to flush a persistence context when the conversation tim

    Torsten Fink Newbie


      we are developing a wizard for creating an offer in several web pages. To reduce database operation we use the manual flush mode. This works good if the user starts the conversation, does his job and ends the conversation.

      But what if he decides to take a break, while the conversation is active and the conversation times out?

      In this case we would like to save his work and give him the option to continue at a later point of time.

      How can we do that?

      I do not find a way to add a callback that is called before the conversation ends. I cannot use the remove-method of a stateful session bean because it is not associated with a transaction and thus I cannot flush the persistence context.

      Any ideas?

      -- Torsten

        • 1. Re: How to flush a persistence context when the conversation
          Gavin King Master

          So what you are saying is: you want to persist stuff in the database, but you don't want to persist stuff in the database?

          Well, you need to choose :-)

          Actually, an option is to set your HttpSession and SFSB timeouts much longer than the passivation time, and let the server serialize the intermediate states to disk.

          • 2. Re: How to flush a persistence context when the conversation
            Torsten Fink Newbie

            I choose to persist them in the database :-)

            My problem is that
            - I only want one access/flush to the database once at the end of the conversation
            - and I do not want to loose any changes the user did to the entity in the conversation scope because of a conversation timeout.

            I already adapted the session and SFSB-life timeouts and made them longer than the conversation timeout.

            (Somehow off-topic:)
            Hm, can SFSB-passivation be a problem?
            A SFSB references an entity of the persistence context and after deserializing a passivated SFSB, the entity would not be connected to the persistence context anymore.
            This would mean that I should always take care that a SFSB with entities is never pasivated?