-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Caching not working
PostPosted: Sun Feb 10, 2013 8:21 am 
Newbie

Joined: Mon Jul 30, 2012 10:17 am
Posts: 3
I'm using hibernate 4.1.9.Final with the following properties:

Quote:
<jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source>
<properties>
<!-- Properties for Hibernate (default provider for JBoss AS) -->
<property name="hibernate.hbm2ddl.auto" value="validate" />
<!-- <property name="hibernate.hbm2ddl.auto" value="create" /> -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.flush_before_completion"
value="true" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.jbc2.JBossCacheRegionFactory" />
<property name="javax.persistence.sharedCache.mode" value="ALL"/>
</properties>


JPA says the default caching behaviour of a provider is unspecified. I found out that hibernate uses no 2nd level cache by default. So I specified the jboss 2nd level cache. But there's still no caching. I can open the same record multiple times and the same query will always be executed. The shared cache mode "ALL" explicitly says, that all entities should be cached no matter what annotation/xml declaration is used.


Top
 Profile  
 
 Post subject: Re: Hibernate Caching not working
PostPosted: Tue Feb 12, 2013 3:23 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi Sanix,

1. For specifying the 2L-cache implementation you should use the property hibernate.cache.region.factory_class.
hibernate.cache.provider_class is old and obsolete.

2. JBossCache is deprecated and should be replaced by is successor Infinispan

N.B.: I just did a small test (I use EHCache as 2ndLevel Cache) and to me

Code:
<property name="javax.persistence.sharedCache.mode" value="ALL"/>   


works great.

These are the further setting I use:
Code:
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/>

    <property name="hibernate.cache.use_structured_entries" value="true"/>
    <property name="hibernate.cache.use_second_level_cache" value="true"/>



Quote:
I can open the same record multiple times ...


How do you do this?
If you use a user-defined-query-to do this, then you have to enable and use also the 2nd-level-Query-cache.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.