4 Replies Latest reply on Dec 7, 2006 12:54 AM by Krishna Attravanam

    Performance question on EntityManager

    Krishna Attravanam Newbie

      Hi All

      I have a scenario and am trying to evaluate the performance of using the entity manager in a Message Driven Bean (MDB)

      class MDBean {
      @persistencecontext(....)
      private EntityManager em;

      public void onMessage() {
      ....
      while (someCondition) {
      ClassB b = new ClassB();
      b.setEntityManager(em);
      b.doSomething();
      }
      ............
      }

      Basically ClassB carries out persisting of about 6 tables based on the entitymanager passed to it. This process happens in a loop and the loop runs for about 10 - 20 times. I was wondering if I need to close the entity maanger at some point and re-create it? What would be the performance hit if any? Let me know what other design considerations need to be taken into account?

      Thanks
      K