ibatis OSCACHE 缓存问题

我今天测试了一下ibatis oscache缓存问题,在测试过程中一直报 No cache entry exists for key='-663355165|24887190', creating
找不到实体对象,哪位高手指点一下,我把配置的代码发一下

这是
<sqlMapConfig>
<settings cacheModelsEnabled="true" maxRequests="256" maxSessions="64" maxTransactions="16"enhancementEnabled="true" lazyLoadingEnabled="true" />
<sqlMap resource="org/lr/ibatis/bean/sqlmap_person.xml"></sqlMap>
</sqlMapConfig>


下面为person pojo实体对象
public class Person implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long id;
private String name;
private String info;
private byte[] info_blob;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getInfo() {
return info;
}

public void setInfo(String info) {
this.info = info;
}

public byte[] getInfo_blob() {
return info_blob;
}

public void setInfo_blob(byte[] info_blob) {
this.info_blob = info_blob;
}

public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Person)) {
return false;
}
Person u = (Person) obj;
if (u.getId() != null && getId() != null)
return u.getId().equals(getId());
return super.equals(obj);
}

public int hashCode() {
if (getId() != null) {
return getId().hashCode();
}
return super.hashCode();
}
}

对应的映射文件 sqlmap_person.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">

<?xml-stylesheet type="text/xsl" href="SpecialDB.xslt"?>
<sqlMap namespace="Person">

<typeAlias alias="Person" type="org.lr.ibatis.bean.Person" />
<cacheModel id="person-cache" type="OSCACHE" readOnly="true">
<flushInterval minutes="10" />
<flushOnExecute statement="queryAll" />
<property name="size" value="1000" />
</cacheModel>

<cacheModel id="save-person-cache" type="OSCACHE" readOnly="true">
<flushInterval minutes="1" />
<property name="size" value="1000" />
</cacheModel>

<select id="queryAll" resultClass="Person" cacheModel="person-cache">
select * from person
</select>

<select id="queryById" parameterClass="java.lang.String"
resultClass="Person" cacheModel ="save-person-cache">
select * from person where id=#id#
</select>

<update id="updateBlob" parameterClass="org.lr.ibatis.bean.Person">
update person set info_blob = #info_blob#
</update>

<insert id="savePerson" parameterClass="org.lr.ibatis.bean.Person">
insert into person(name,info,info_blob) values(#name#,#info#, #info_blob#)
</insert>
</sqlMap>

oscache 属性文件 oscache.properties

cache.memory=true
cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
cache.capacity=1000


在做单元测试的时候一直报
Cache : No cache entry exists for key='-663355165|24887190', creating

我觉得正常的话,第一次查询后台执行数据库查询,第二次肯定是从缓存中取呢,
可是一直有问题,这还需要设置什么地方呢,高人指点一下
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值