我添加了以下注释以启用对我的 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 http://java.sun.com/webapps/bugreport)
检查 Bug Parade 后
重复。包括您的程序和
您的以下诊断
报告。谢谢。
com.sun.tools.javac.code.Symbol$CompletionFailure:
类文件为
org.hibernate.annotations.CacheConcurrencyStrategy
未找到
任何人都可以在这里帮助我并让我知道我需要做什么或目前做错了什么?
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
将解决问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)