当尝试从 javax.persistence 使用 @Index 注释时,Eclipse会给我这个错误。
When trying to use the @Index annotation from javax.persistence, Eclipse gives me this error.
我在 java.util.Date 字段之前使用它,在使用 @Entity 。
I'm using it right before a java.util.Date field, inside a class annotated with @Entity.
之前,我使用 org.hibernate.annotations.Index 在完全相同的地方,它很好。
Before, I was using org.hibernate.annotations.Index in the exact same place and it was fine.
我从 4.1升级 hibernate-core 后问题开始了.9.Final 到 4.3.0.Beta3 和 hibernate-commons-annotation 从 4.0.1 到 4.0.2 。它说 @Index 已被弃用,建议 javax.persistence 一。
The problem started after I've upgraded hibernate-core from 4.1.9.Final to 4.3.0.Beta3 and hibernate-commons-annotations from 4.0.1 to 4.0.2. It says @Index is deprecated and recommends the javax.persistence one.
我发现的所有文档和示例都在课程成员之前加上 @Index 。我缺少什么?
All docs and examples I've found put @Index before class members. What am I missing?
推荐答案JPA索引注释只能用作之类的另一个注释的一部分@Table , @SecondaryTable 等(参见 javadoc ):
The JPA Index annotation can only be used as part of another annotation like @Table, @SecondaryTable, etc. (see the See Also section in the javadoc):
@Table(indexes = { @Index(...) })更多推荐
此位置不允许使用注释@Index
发布评论