首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

JBoss4.2.x中起用JPA二级缓存

2012-11-01 
JBoss4.2.x中启用JPA二级缓存JPA SPEC中没有定义关于一级、二级缓存的规范(事实上JCP对各JSR都很少定义涉及

JBoss4.2.x中启用JPA二级缓存

JPA SPEC中没有定义关于一级、二级缓存的规范(事实上JCP对各JSR都很少定义涉及性能优化规范),要启用二级缓存需要使用JPA Provider专有的配置,JBoss(Hibernate)中配置如下。

?

Specify the following code piece in persistence-unit.xml#/persistence-unit/properties/

?

<property name="hibernate.cache.use_query_cache" value="true" /><property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />

?

Add an '@Cache' annatation to the entity class, and choose the right caching strategy.

import org.hibernate.annotations.Cache;import org.hibernate.annotations.CacheConcurrencyStrategy;
?
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
?

?

热点排行