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" />
这是一里面的一条信息。