【问题标题】:hibernate don't read from ehcache.xml OR not timeout?休眠不从 ehcache.xml 读取或不超时?
【发布时间】:2010-12-23 02:21:34
【问题描述】:

这就是我的实体的样子

@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 {

我的 ehcache.xml

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

问。我已经将时间设置为零并将永恒设置为假,但是当我尝试从 db.load 加载实体时。它仍然从缓存中获取。 time=0 表示没有缓存对吗?我错过了什么吗?

参考:我的 appcontex.xml 在http://www.copypastecode.com/16833/

【问题讨论】:

    标签: java hibernate spring ehcache


    【解决方案1】:

    timeToIdleSeconds 和 timeToLiveSeconds 都将零视为无穷大。它不会从我的 iPhone 上正确剪切和粘贴,但如果您在 ehcache 配置文档 here 上查找 timeToLiveSeconds,它会显示“值为 0 意味着元素可以无限存在。”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-30
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 2012-03-31
      • 2018-11-05
      • 2010-10-12
      • 2016-11-15
      相关资源
      最近更新 更多