-->
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: Hibernate EHCache query cache with criteria
PostPosted: Wed Apr 17, 2013 10:20 am 
Newbie

Joined: Wed Apr 17, 2013 9:56 am
Posts: 5
I think there is a point that I have not understand yet. I have a class witch have 3 collections of elements in attribute
Code:
public class Pays implements Serializable{
private static final long serialVersionUID = -8767337896773261244L;
/**
* the id of the country
*/
private long id;

/**
* name of the country
*/
private String nom;
/**
* The region of the country
*/
private Region region;
/**
* Relations between a country and a composant
*/
private Set<PaysComposants> pc = new HashSet<PaysComposants>(0);
/**
* Relations between a country and a service
*/
private Set<PaysServices> ps = new HashSet<PaysServices>(0);
/**
* Relations between a country and some keys figures
*/
private Set<KeyFigure> kf = new HashSet<KeyFigure>(0);


on each class and on each getter onf collection, I put
Code:
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
.

Actually, the only object put in cache is the only the Pays p, the others collections pc, ps and kf are not put in cache.

here is my ehCache.xml
Code:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">

<defaultCache maxElementsInMemory="100000" eternal="false"
    timeToIdleSeconds="3600" timeToLiveSeconds="3600" overflowToDisk="true" />

<cache name="org.hibernate.cache.internal.StandardQueryCache"
    maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="3600"
    timeToLiveSeconds="3600">
</cache>

<cache name="org.hibernate.cache.spi.UpdateTimestampsCache"
    maxElementsInMemory="10000" eternal="true">
</cache>


My hibernate properties
Code:
<property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="current_session_context_class">thread</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.use_structured_entries">true</prop>
            <prop key="hibernate.cache.generate_statistics">true</prop>
            <prop key="hibernate.cache.provider_class">
                org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="hibernate.cache.region.factory_class">
                org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
            </prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">
                applicationContext-ehCache-entity.xml
            </prop>

        </props>
    </property>


I hope that you will help me :)


Top
 Profile  
 
 Post subject: Re: Hibernate EHCache query cache with criteria
PostPosted: Thu Apr 18, 2013 3:38 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I put the @Cache annotation direct above the collection declaration itself and my collections get effectively cached in EHCache

Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region="CollectionEternal")
private Set<AOAccountPeer> aggAOAccount = new java.util.HashSet();


Top
 Profile  
 
 Post subject: Re: Hibernate EHCache query cache with criteria
PostPosted: Thu Apr 18, 2013 4:06 am 
Newbie

Joined: Wed Apr 17, 2013 9:56 am
Posts: 5
nothing change when I move the cache declaration from the getter to the definition of the set


Top
 Profile  
 
 Post subject: Re: Hibernate EHCache query cache with criteria
PostPosted: Thu Apr 18, 2013 4:08 am 
Newbie

Joined: Wed Apr 17, 2013 9:56 am
Posts: 5
pb00067 wrote:
I put the @Cache annotation direct above the collection declaration itself and my collections get effectively cached in EHCache

Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region="CollectionEternal")
private Set<AOAccountPeer> aggAOAccount = new java.util.HashSet();


nothing change when I move the cache declaration from the getter to the definition of the set


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.