I am currently working on a project with Spring and Hibernate.
In one part i have to do a lot of lookups in the database.
If i do this with :
HibernateTemplate hibernateTemplate = getHibernateTemplate();
Then the perfomance is very poor, it seems it dosent use the 2 lvl cache at all, wich as far as i understand also is in accordance with the documentation for find().
I have tried with the HibernateCallback method, and this performs poorly aswell !!! Even tough you here have the option of creating the query directly on the hibernate session, it still seems to go directly to the database without using the cache.
If i use hibernate directly like this :
then the performance is much better (by a factor 8) since now it uses the cache.
My question is then, how do i use HibernateTemplate together with a query cache ???
I use Hibernate 2.1.6, Spring 1.1.5 and Ehcache 1.1.