首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

ibatis OSCACHE 缓存有关问题

2012-10-18 
ibatis OSCACHE 缓存问题我今天测试了一下ibatis oscache缓存问题,在测试过程中一直报No cache entry exis

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" resultcacheModel="person-cache">
select * from person
</select>

<select id="queryById" parametercacheModel ="save-person-cache">
select * from person where id=#id#
</select>

<update id="updateBlob" parameterparameterClass="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

我觉得正常的话,第一次查询后台执行数据库查询,第二次肯定是从缓存中取呢,
可是一直有问题,这还需要设置什么地方呢,高人指点一下

热点排行