简体   繁体   English

休眠不从ehcache.xml读取,还是没有超时?

[英]hibernate don't read from ehcache.xml OR not timeout?

This is how my entity look like 这就是我的实体样子

@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)   

@Table(name = "TestPojoOnly")
@NamedQueries({@NamedQuery(name = "TestPojoOnly.findAll", query = "SELECT h FROM TestPojoOnly h"), @NamedQuery(name = "TestPojoOnly.findById", query = "SELECT h FROM TestPojoOnly h WHERE h.id = :id"), @NamedQuery(name = "TestPojoOnly.findByCategoryname", query = "SELECT h FROM TestPojoOnly h WHERE h.categoryname = :categoryname")})
public class TestPojoOnly implements Serializable {

my ehcache.xml 我的ehcache.xml

<cache name="com.package.model.TestPojoOnly"
    maxElementsInMemory="200"
    eternal="false"
    overflowToDisk="false"
    timeToIdleSeconds="0"
    timeToLiveSeconds="0"
/>

Q. I already set time to Zero and eternal to false, but when i try load entity from db. 问:我已经将时间设置为零,并将eternal设置为false,但是当我尝试从db加载实体时。 it still get from cache. 它仍然从缓存中获取。 time=0 that mean no cache right? time = 0表示没有缓存吗? did i miss out something? 我错过了什么吗?

ref: my appcontex.xml at http://www.copypastecode.com/16833/ 参考: http ://www.copypastecode.com/16833/上的我的appcontex.xml

timeToIdleSeconds and timeToLiveSeconds both treat zero as infinity. timeToIdleSeconds和timeToLiveSeconds都将零视为无穷大。 It wouldn't cut and paste properly from my iPhone, but if you do a find on the the ehcache configuration doc here for timeToLiveSeconds it says "A value of 0 means that an Element can live for infinity." 它无法从我的iPhone中正确剪切和粘贴,但是如果您在ehcache配置文档中找到 timeToLiveSeconds,它会显示“值0表示元素可以无限生存”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM