2 Replies Latest reply on Aug 23, 2006 12:55 AM by Bhalchandra Gokhale

    proper usage of persistencecontexts/entitymanagers

    Bhalchandra Gokhale Newbie

      i have the following code

      class Navigator {
      @PersistenceContext (type=EXTENDED)
      EntityManager em;

      List userList = new ArrayList();

      public void init() {
      userList = em.createQuery("select u from User u").getResultList();

      public void addUser(User u) {

      Then I have another SLSB to add new Users like so:

      class ActionBean {
      EntityManager em;

      @In Navigator n;

      public void addUser (User u) {

      Basically, user saved using one EntityManager (in the slsb) is added to a list that is attached to an extended persistence context.
      Is the underlying peresistence context the same ?
      This seems to be working fine but wanted to endorse it from the experts.