-->
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: Ehcaching Hibernate
PostPosted: Thu May 27, 2010 4:18 pm 
Newbie

Joined: Thu May 27, 2010 3:44 pm
Posts: 1
Hi All

We have a requirement at a customer where
. we only need to cache tables that we read from
. not cache tables from we read and write from

In order to accomplish the same I have used the Ehcache 1.2.3 with hibernate 3.5. I could not use other versions of ehcache becuase it had problems with finding the ehcache.xml inspite of it being at the classpath level.

The calls that are getting afftected with the above requirement is get and createQuery(set to cachable).

The following settings in the ehcache configuration has worked for me in my sample project.

1. I have set the cache usage to read-only for read only tables.
2. I set the read-write in the cache usage for the read-write tables.
3. In the ehcache I have overided the read-write regions with values to zero; since I did not want it to be cache.
4. In the ehcache I have used readly to 15 mins.
5. I have set the defaults to 0.
6. Overided the standarized cache to zero with having maxelements to 10.

I am attaching the datasources and ehcache.xml files to this post.

Kindly advise if I am doing anything wrong to accomplish the requirement.

<defaultCache maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="org.hibernate.cache.StandardQueryCache" maxElementsInMemory="10" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.Country" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="120" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.AddressRecord" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.BusinessDayOverride" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ChargeType" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ChargeTypeTaxOverride" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.CompanyCreditCard" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.CreditCardMultilingualDesc" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.CreditCardType" maxElementsInMemory="100000" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="900" overflowToDisk="false" />





<cache name="com.partylite.ge.persistence.hibernate.ConsultantDemographic" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ConsultantLocator" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ConsultantDemographicChange" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ConsultantSocialSecurity" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ConsultantSocialSecurityChange" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ConsultantWebsite" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />
<cache name="com.partylite.ge.persistence.hibernate.ElectronicServicesStatus" maxElementsInMemory="0" eternal="false" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" />[code][/code]


Top
 Profile  
 
 Post subject: Re: Ehcaching Hibernate
PostPosted: Mon May 31, 2010 5:11 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
2. I set the read-write in the cache usage for the read-write tables.
3. In the ehcache I have overrided the read-write regions with values to zero; since I did not want it to be cache.


In my opinion there seems to be all right to accomplish the requirement, just one thing:
If you don't want cache usage for the read-write tables,
then personally I would simply do not configure them for being cached in 2L at all.

In other words:
Instead to define
Code:
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class com.partylite.ge.persistence.hibernate.ConsultantDemographic


and defining maxElementsInMemory="0" , overflowToDisk="false" on regarding cacheRegion.
simply omit the @Cache tag on this class.


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.