Hi all! I'm trying to introduce the 2nd level cache (Using JBoss cache implementation) in my project. I've started with a single query:
Query query = em.createQuery("FROM Customer where id=:id"); query.setParameter("id", id); Customer customer = (Customer)query.getSingleResult();
The Customer entity is mapped with : @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL, region="customers")
However if I issue the query several time, I can see that even if data is added in the cache, but Hibernate dumps sql for every query (So i presume data is not retrieved from the Cache)
entries{1=CacheEntry(com.sample.Customer)[XYZ,1,John Smith]}
[STDOUT] Hibernate: select customer0_.ID as ID21_, customer0_ .COUNTRY as COUNTRY21_, customer0_.NAME as NAME21_ from customer customer0_ wher e customer0_.ID=? limit ?
So I beg you to explain me what does it mean that Entity in the cache, if Hibernate doesn't use it ? should I design all my queries with Session.load rather ? thanks a lot Emiliy
|