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?
|