-->
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.  [ 4 posts ] 
Author Message
 Post subject: 2nd level Cache Query level Cache with JPA and Hibernate
PostPosted: Wed Apr 04, 2012 4:52 am 
Newbie

Joined: Wed Apr 04, 2012 4:37 am
Posts: 2
Hi All,

I have configured 2nd level caching through JPA and Hibernate guidelines. The setup seems to be working, as I see query results being cached and also following warnigns while deploying the jar file. May I know the reason for showing these warnings? How can I fix these warnings? It seems that the ehcache.xml configs are not picked up for non defaults.
**************************************
14:02:08,753 WARN [Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
14:02:08,815 WARN [AbstractEhcacheProvider] Could not find a specific ehcache configuration for cache named [persistence.unit:unitName=TestCacheEJB.jar/#TestCache.test.SysSecureElementProfileEntity]; using defaults.
14:02:08,846 WARN [AbstractEhcacheProvider] Could not find a specific ehcache configuration for cache named [persistence.unit:unitName=TestCacheEJB.jar/#TestCache.org.hibernate.cache.UpdateTimestampsCache]; using defaults.
14:02:08,846 WARN [AbstractEhcacheProvider] Could not find a specific ehcache configuration for cache named [persistence.unit:unitName=TestCacheEJB.jar/#TestCache.org.hibernate.cache.StandardQueryCache]; using defaults.

******************************************
Here are configurations....

persistence.xml:-
============
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">

<persistence-unit name="TestCache" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/xxxxx</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.show_sql" value="true" />
<!--
<property name="hibernate.query.factory_class" value="org.hibernate.hql.ast.ASTQueryTranslatorFactory" />
-->
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider" />
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>
<property name="hibernate.ejb.classcache.test.SysSecureElementProfileEntity" value="read-write, test.SysSecureElementProfileEntity"/>
</properties>
</persistence-unit>
</persistence>

ehcache.xml :
==========
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
diskPersistent="false"
timeToLiveSeconds="1800"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<cache
name="persistence.unit:unitName=TestCacheEJB.jar/#TestCache.test.SysSecureElementProfileEntity" maxElementsInMemory="100" eternal="false" timeToLiveSeconds="1800" overflowToDisk="false" />
<cache
name="test.SysSecureElementProfileEntity" maxElementsInMemory="100" eternal="false" timeToLiveSeconds="1800" overflowToDisk="false" />
<cache
name="org.hibernate.cache.StandardQueryCache"
eternal="false"
timeToLiveSeconds="120"
overflowToDisk="true"/>
<cache
name="org.hibernate.cache.UpdateTimestampsCache"
eternal="true"
overflowToDisk="true"/>
</ehcache>


Top
 Profile  
 
 Post subject: Re: 2nd level Cache Query level Cache with JPA and Hibernate
PostPosted: Wed Apr 04, 2012 10:36 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
It seems that the ehcache.xml configs are not picked up for non defaults.


Where did you place ehcache.xml?
Ehcache looks for a file called ehcache.xml in the top level of the classpath so
you must place it in a directory which is referenced directly by your classpath.


Top
 Profile  
 
 Post subject: Re: 2nd level Cache Query level Cache with JPA and Hibernate
PostPosted: Wed Apr 04, 2012 11:56 pm 
Newbie

Joined: Wed Apr 04, 2012 4:37 am
Posts: 2
Thank you so much for replying.

I'm using JBOSS 5.1 GA server and have placed the ehcache.xml under server/default/conf directoty. I can see that ehcache.xml is being read during the deployment.

The problem with <cache> tags, whatever name I have given for the cache name is not able to idetify and always it seems that using the default one.

some how the jboss is generating the huge text key to identify the cache entry in the ehcache.xml. I dont understand why is not generating the different cache name?
persistence.unit:unitName=TestCacheEJB.jar/#TestCache.org.hibernate.cache.StandardQueryCache
I'm looking that system should look for cache name as "org.hibernate.cache.StandardQueryCache"

<cache
name="org.hibernate.cache.StandardQueryCache"
eternal="false"
timeToLiveSeconds="120"
overflowToDisk="true"/>


and it shows following warning
14:02:08,846 WARN [AbstractEhcacheProvider] Could not find a specific ehcache configuration for cache named [persistence.unit:unitName=TestCacheEJB.jar/#TestCache.org.hibernate.cache.StandardQueryCache]; using defaults.


Top
 Profile  
 
 Post subject: Re: 2nd level Cache Query level Cache with JPA and Hibernate
PostPosted: Thu Apr 05, 2012 2:07 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I fear that one of the special characters /#.:= is creating the trouble.
Probably this is a problem which is solved in newer Jboss Server versions,
have you to possibility to try with JBOSS 7 ?


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