此位置不允许使用注释@Index

编程入门 行业动态 更新时间:2024-10-26 08:22:37
本文介绍了此位置不允许使用注释@Index的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当尝试从 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

本文发布于:2023-11-12 19:05:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582284.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   注释   位置   Index

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!