配置ehcache.xml -----02

配置ehcache.xml文件

1. 在Hibernate配置文件中设置:
    

<!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
        <list>
            <value>com/ouou/model/Videos.hbm.xml</value>   
         </list>
         </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.current_session_context_class">thread</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
                <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
                <!--add ehcache-->
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.use_query_cache">false</prop><!-- 是否使用查询缓存 -->
                <!--
                <prop key="hibernate.cache.provider_configuration_file_resource_path">/ehcache.xml</prop>
                <prop key="hibernate.show_sql">true</prop>
                -->
                <!--<prop key="hibernate.transaction.auto_close_session">true</prop>-->
                <prop key="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
                <!-- Create/update the database tables automatically when the JVM starts up
                 <prop key="hibernate.hbm2ddl.auto">update</prop> -->
                <!-- Turn batching off for better error messages under PostgreSQL -->
                <prop key="hibernate.jdbc.batch_size">25</prop>
                <!--
                <prop key="hibernate.connection.pool_size">10</prop>
                -->
            </props>
        </property>
    </bean>


    如果不设置“查询缓存”,那么hibernate只会缓存使用load()方法获得的单个持久化对象,如果想缓存使用findall()、 list()、Iterator()、createCriteria()、createQuery()等方法获得的数据结果集的话,就需要设置hibernate.cache.use_query_cache true 才行

 

你可能感兴趣的:(配置ehcache.xml -----02)