@Cache注释用法错误 [英] @Cache annotation usage error
问题描述
我添加了以下批注以启用对我的EJB3实体之一的缓存,以测试使用ehCache的缓存,在这里我将Hibernate用作持久性提供程序:
I added the following annotation to enable cache to one of my EJB3 entities, to test caching with ehCache, where I use Hibernate as the persistence provider:
....
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中添加了以下内容:
I added the following to 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"/>
当我尝试编译时,出现以下错误:
And when I try to compile I get the following error:
/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 找不到
/persistence/F.class): warning: Cannot find annotation method 'usage()' in type 'org.hibernate.annotations.Cache': class file for org.hibernate.annotations.Cache not found An exception has occurred in the compiler (1.6.0_16). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.hibernate.annotations.CacheConcurrencyStrategy not found
有人可以在这里帮助我,让我知道我需要做的还是当前做错了什么?
Can anyone help me out here and let me know what I need to do or am doing wrong currently ?
推荐答案
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
将解决问题
这篇关于@Cache注释用法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!