[jboss-user] [EJB 3.0] - Why is

heinrich do-not-reply at jboss.com
Mon Nov 20 03:55:38 EST 2006


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987235#3987235

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987235



More information about the jboss-user mailing list