Hi there,
the first statement in the session takes very long to execute (800-900ms). Subsequent (not-related) find calls (or anything else) after that are fast again.
Code:
hs = HibernateUtils.getSession(loginId);
tx = hs.beginTransaction();
start=System.currentTimeMillis();
Iterator it = hs.find("from DO_Test").iterator();
stop=System.currentTimeMillis();
start=System.currentTimeMillis();
Iterator it2 = hs.find("from DO_Test2").iterator();
stop=System.currentTimeMillis();
tx.commit();
The first find statement takes 800ms(!), the second <10ms. This is repeatable, and it is always the statement that comes first that takes so long (if the statements are exchanged, the statement located right after beginTransaction() is the one which takes just too long). My guess is, that the session is initialized just before executing the first statement. How can this be improved?
Hibernate 2.1.3, JBoss 3.2.2, PostgreSQL 7.4.1
Thanks,
Thomas