Hi All!
I am using the Hibernate 3.2.6GA with Java 6 and I am expiriencing the performance problems by calling Hibernate session.get(class Class, id Serializable) method. I am using EhCache (1.6.0), and I am trying to retrieve already cached objects using session.get method. Here is the piece of test code:
Code:
private void testCache() {
Session currentSession = HibernateUtil.getCurrentSession();
//read all keys from DB for testing
List list = currentSession.createSQLQuery("select employee_key from employee")
.addScalar("employee_key", Hibernate.LONG ).list();
//retrieve objects from cache
for(Object elem : list){
currentSession.get(DBEmployee.class, (Serializable)elem);
}
System.out.println("ready");
}
The DBEmployee entity has a cache. I do not see any SQL statements from Hibernate during this method run, since all objects are precached already. There are about 30.000 employee objects. Profiling this method I get the following picture:
Whole test method run takes about 27 seconds, whereas the fireLoad takes about 2 seconds only. Why it is needed to spent another 25 seconds for some 'afterTransactionCompletion' call, if I even haven't started any transaction there?
Thank you for your answers!