-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate 2nd level beginner question
PostPosted: Wed Jul 28, 2010 4:04 am 
Newbie

Joined: Wed Jul 28, 2010 3:45 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.