-->
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.  [ 3 posts ] 
Author Message
 Post subject: L2 Cache Question
PostPosted: Wed Jul 25, 2007 7:42 pm 
Newbie

Joined: Wed Jul 25, 2007 7:04 pm
Posts: 3
Hello,

I am using Hibernate 3.2.3 with JPA. I have a question about using L2 cache. The only way I can get the L2 cache to work is to use EntityManager.find() which requires an entity class and a primary key. However this method does not fit into something that I want to accomplish.


There are several small tables that I want them to be cached once they are queried for the first time. To accomplish this goal, I use EntityManager.createQuery("select e from EntityClass e"). The idea is to run this query once at server startup time so that these small tables are cached. But the observation is that every time this query is ran, Hibernate opens a JDBC connection. The debug message says these entries are cached but then the next run triggers another JDBC connection.

Simon[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
use
query.setHint("org.hibernate.cacheable", true);
(check the ref doc to be sure), and enable the query cache in persistence.xml

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 8:25 pm 
Newbie

Joined: Wed Jul 25, 2007 7:04 pm
Posts: 3
Yes, the query hint works. Now I can see cache hits when I run the same query twice. Thank you very much.


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

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.