【发布时间】:2010-12-09 11:52:43
【问题描述】:
我添加了以下注释以启用对我的 EJB3 实体之一的缓存,以使用 ehCache 测试缓存,其中我使用 Hibernate 作为持久性提供程序:
....
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
@Entity
@Table(name = "F")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@NamedQueries({ @NamedQuery(name = "F.findAll", query = "SELECT f FROM F f")})
public class F implements Serializable {
.....
}
我在 persistence.xml 中添加了以下内容:
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
当我尝试编译时,出现以下错误:
/persistence/F.class):警告:不能 在中找到注释方法'usage()' 类型 'org.hibernate.annotations.Cache': 类文件 org.hibernate.annotations.Cache 不 发现发生了异常 编译器(1.6.0_16)。请提交错误 在 Java 开发者连接 (http://java.sun.com/webapps/bugreport) 在检查了 Bug Parade 之后 重复。包括你的程序和 您的以下诊断 报告。谢谢你。 com.sun.tools.javac.code.Symbol$CompletionFailure: 类文件 org.hibernate.annotations.CacheConcurrencyStrategy 没找到
谁能在这里帮助我,让我知道我现在需要做什么或做错了什么?
【问题讨论】:
标签: hibernate caching ejb-3.0 ehcache java-ee-5