1 Reply Latest reply on Aug 24, 2006 4:20 PM by Norman Richards

    Please explain entity Scope

    Samuel Mendenhall Apprentice

      Can someone explain to me the details of scoping with entity beans. The majority if not all of the examples I've seen show entitiy beans using the session scope. Like in the seam documentation:

      @Name("user")
      @Entity
      @Scope(SESSION)
      public class User {
       ...
      }
      



      So what does this exactly mean that the 'user' entity bean lives in the Session scope, does this mean that in Bijection the user bean is literally in the session scope even if the EJB3 accessing the user entity bean is Stateless?

      So if I changed the @Scope(SESSION) to @Scope(EVENT) then the user bean would only stay in the EVENT/request scope during bijection?

      Help understanding this would be greatly appreciated.

        • 1. Re: Please explain entity Scope
          Norman Richards Master

          Setting the scope to session doesn't mean that all User instances live in the session. It means that there is one seam component type called "user" that seam will manage in the session. Usually this would be to manage the instance of the user that represents the current logged in user. Perhaps it would be clearer if the component name were "currentUser".

          Remember, of course, that a EJB3 bean can have multiple roles in Seam. If you used User in another way in the same application, you could give the component another role. (an additional name/scope)

          To answer your question, yes it means that the seam-managed "user" component would be stored in the session. The fact that you are accessing from a stateless component is not relevant. Yes, changing it to EVENT would store it in the request. I think entities default to conversation scope if you don't specify otherwise.