Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-5714

JPA "Session Open Count" statistic appears to be bogus

    XMLWordPrintable

Details

    Description

      After running a small sample app, Session Open Count in the admin console displays 900006. Session close count is 1 (as expected). Memory usage does not significantly increase.

      The sample app exposes an EntityManager like this:

      @Produces
      public EntityManager getEntityManager() {
      System.out.println("Getting entity manager!");
      return entityManager;
      }

      A JAX-RS service then injects the entity manager, and performs a few simple queries:

      @Inject
      private EntityManager entityManager;

      @GET()
      @Produces("text/plain")
      public String sayHello() {
      try {
      userTransaction.begin();
      Car car = new Car();
      car.setCarName("Name: " + System.currentTimeMillis());
      entityManager.persist(car);

      Car car2 = new Car();
      car2.setCarName("Name: " + System.currentTimeMillis());
      entityManager.persist(car2);

      for (int i = 0; i < 900000; i++) {
      Query q = entityManager.createQuery("select c from Car c");
      List<Car> resultList = q.getResultList();
      for (Car c : resultList)

      { System.out.println("Car: " + c); }

      }
      return "stub";
      }

      I don't see any way that this could actually be opening this many sessions.

      Attachments

        Activity

          People

            rhn-support-hbraun Heiko Braun
            jsightle@redhat.com Jess Sightler
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: