我可以使用 ehcache 搜索 API 搜索二级缓存吗?
如果我直接使用方法用对象填充缓存,put()
则可以使用 SearchAttribute 进行搜索。当我尝试查询二级 Hibernate 缓存时,我被困在从 ehcache 中对象的反汇编状态组装实体。
public class TestExtr implements AttributeExtractor {
@Override
public Object attributeFor(Element element, String arg1)
throws AttributeExtractorException {
return element.?() ; //how to cast its value to Employee?
}
}
我的实体示例
public class Employee implements Serializable {
private int id;
private String firstName;
private String lastName;
private int salary;
// getters and setters
}
Element element
二级缓存的值为:
org.hibernate.cache.ehcache.internal.strategy.AbstractReadWriteEhcacheAccessStrategy$Item@6b8efd7c
key = test.Employee#1383
CacheEntry(test.Employee)[aaaaa,dd,77]