5 Replies Latest reply on Oct 13, 2006 9:55 PM by gavin.king

    The scope of Seam-managed Hibernate Session

    littlesuns

      hi,everyone,
      I have a question about The scope of Seam-managed Hibernate Session,in the Seam Doc we know the Seam-managed Hibernate Session was a component of Seam,and its scope is Conversation,that is mean,the managed Session can be created and destroyed,here is the question,we inject a managed Session in a Session scope or a Conversation scope Seam Component,when the managed Session will be destroyed?

      3Q4U help.

        • 1. Re: The scope of Seam-managed Hibernate Session
          gavin.king

          What you inject something into does not affect its lifecycle. Note that in Seam "injection" is a very transient thing that lasts only for a single method call.

          • 2. Re: The scope of Seam-managed Hibernate Session
            littlesuns

            Thank you for your answer,Gavin.
            if I hava a Seam component ActionA like that:

            @Scope(ScopeTypw.CONVERSATION)
            public class ActionA{
            
            //seam-managed hibernate session
            @In(create=true)
            private Session s;
            
            }
            

            when we invoke a method of ActionA,there will be a Session s injected,but the managed Session has its own scope as a component,what I want to know is not when the Session inject,I want to know when the injected Session will be destryed,because the Session is controled by Seam and the Scope of Conversation is not a "Exact" concept,BTW,the managed session is a Converstaion Scope,it is mean that we will (or could) have many exist Sessions if every Action inject a hibernate Session,am I right?

            • 3. Re: The scope of Seam-managed Hibernate Session
              gavin.king

              No no no!

              There is at most one Session named "s" for each conversation, and it is destroyed when the conversation ends.

              Are you sure you really understand what a conversation is?

              • 4. Re: The scope of Seam-managed Hibernate Session
                littlesuns

                thank you for your reply;
                I think now I have known how it work a little,the managed-session and the ActionA have their own lifecycle,when the ActionA needs a Session "s",a managed-session in the ConversationContext will be injected into the ActionA,and the managed-session will be destroyed when its own lifecycle end,right?

                • 5. Re: The scope of Seam-managed Hibernate Session
                  gavin.king

                  Right.