0 Replies Latest reply on Nov 20, 2006 3:55 AM by heinrich

    Why is

    heinrich

      Hi,

      im wondering why searching entities by using em.find is quite expensive in contrast to a named query.

      The code:

       Ball b = em.find(Ball.class, 34);
      


      is much slower than this:
      Query q = em.createQuery("SELECT Object(o) FROM Ball o WHERE id=:id");
      q.setParameter("id", 34);
      Ball b = q.getSingleResult();
      


      Is used to retrieve my entities the "find" way in my application, unless i resolved gracefull perfomenace problems.
      The query is more than five times faster than the find.
      Why?

      Greetings
      Martin