-->
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: Problems using caching with Hibernate
PostPosted: Fri Aug 13, 2010 10:20 am 
Newbie

Joined: Sun Feb 05, 2006 8:56 pm
Posts: 9
I am trying to enable caching for Hibernate.
I have this in my persistence.xml:

Code:
   <property name="hibernate.show_sql" value="true" />
   <property name="hibernate.cache.use_second_level_cache" value="true" />
   <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory" />


And I put this in my persisted object:

Code:
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.TRANSACTIONAL)


When I access a page that displays the object, I see in the console all the SQL queries performed.
When I reload the page I still see queries even though they are not all the same (checked with diff, most are the same, but not all).
Is this normal behavior ?
I expected that the 2nd time the page is loaded no SQL would be displayed in the console.

If this isn't normal behavior, what should I change in order to use the cache ?
How can I make sure the cache is used and the DB is not accessed at all ?

Ideally I would load in memory a bunch of top level objects that have a lot of dependencies (including the dependencies) so when the users browse/edit pages related to a certain object or its dependencies, the cache is used instead of accessing the DB.

Thx.


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.