首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

SSH中怎么配置Hibernate的二级缓存

2012-04-27 
SSH中如何配置Hibernate的二级缓存SSH中如何配置Hibernate的二级缓存[解决办法]bean idsessionFactory

SSH中如何配置Hibernate的二级缓存
SSH中如何配置Hibernate的二级缓存

[解决办法]
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />

<property name="mappingDirectoryLocations">
<list><value>classpath:/com/xxx/xxx/dao/hbm</value></list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.default_batch_fetch_size">10</prop>

<prop key="hibernate.jdbc.fetch_size">10</prop>
<prop key="hibernate.jdbc.batch_size">5</prop>

<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
</props>
</property>


</bean>




<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>

[解决办法]
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">
true
</prop>

这样写,再加上ehcache.xml的缓存文件:
<cache name="com.model.Role" maxElementsInMemory="5"
eternal="false" timeToIdleSeconds="100" timeToLiveSeconds="180"
overflowToDisk="false" />
这是一里面的一条信息。

热点排行