-->
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: Cache and lifetime
PostPosted: Thu Nov 15, 2012 2:23 pm 
Newbie

Joined: Thu Nov 15, 2012 1:57 pm
Posts: 2
I am pretty much a newbie as goes for hibernate, but I hope you guys can help me.

I am using JBoss and have a lot of EJB3 entities with hibernate cache annotations on, that works fine but I need to auto invalidate the cache after a time period, this is different between the different entities.

I have found some examples where it seems like you can set region with the cache annotation and in a XML file can specify the timetolive on each region, that seems ok. But I have only found examples with ecache, perhaps you can help me.

Here is my persistence.xml

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SybaseDialect" />
<!-- Print nice SQL on stdout -->
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" 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.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/>
<property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>
<property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>
<property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/>
</properties>

and a example of one of the entities

@NamedQueries( { @NamedQuery(name = "Currency:findCurrencyByNumberOrCode", query = "select c from Currency c where (c.number = :number or c.code = :code) and c.inactive = false", hints={ @javax.persistence.QueryHint(name = "org.hibernate.cacheable", value = "true") }) })
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)

@Entity
@Table(name = "currency", uniqueConstraints = {})

I use JBoss 4.2 perhaps there is a xml file in the server deploy folder or something where I can set timetolife for the regions?


Top
 Profile  
 
 Post subject: Re: Cache and lifetime
PostPosted: Thu Nov 15, 2012 4:12 pm 
Newbie

Joined: Thu Nov 15, 2012 1:57 pm
Posts: 2
What about the JMX web console is it possible to clear cache from there ?


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.