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).
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");
}
}