Hibernate中配置EHCache

    技术2022-05-11  87

    <property name="hibernate.cache.provider_class">  net.sf.ehcache.hibernate.Provider </property>

     

    如果需要在查询中使用EHCache,则配置: <property name="hibernate.cache.use_query_cache">true</property>

     

    同时在需要进行缓存的对象的HBM文件中加入<cache usage="read-write"/>

    其中usage 可以为read-write,nonstrict-read-write,read-only

    最后,还要在ehcache.xml中为需要缓存的Class进行配置

    < ehcache >    < cache  name ="cn.hxex.exam.model.User"                maxElementsInMemory ="10000"                eternal ="false"                timeToIdleSeconds ="300"                timeToLiveSeconds ="600"                overflowToDisk ="false"     /> </ ehcache >


    最新回复(0)