1 2 Previous Next 16 Replies Latest reply on Sep 4, 2007 4:00 PM by pmuir Go to original post
      • 15. Re: Seam-Managed Persistence Context

        I should add that I'm currently doing mostly extended persistence in SFSBs, but I do have the occasional LIE where I wasn't exepcting one (and have ended up with a bit more in the way of defensive .merge() calls than I really like).

        • 16. Re: Seam-Managed Persistence Context
          pmuir

          I would do something like - obviously you need to deal with the case your id is null better...

          @Name("currentUserManager")
          @Scope(CONVERSATION)
          public class CurrentUserManager {
          
           @In(required="false", value="currentUserId") @Out(scope=SESSION, value="currentUserId")
           private Object id;
          
           @In
           EntityManager entityManager;
          
           @Factory
           public User getCurrentUser() {
           if (id != null) {
           return entitymanager.find(User.class, id);
           }
           return new User("noone");
           }
          
          }


          1 2 Previous Next