我正在尝试测试自2.1以来可用的JPA的@Index注释。但是我找不到文档如何使用它。
当我尝试时:
@Index(columnList = "firstName")
private String firstName;
..然后Eclipse说:“这个位置不允许注释@Index”
有谁知道如何使用它?或者找到了它的文档? : - )
感谢您的任何建议!
答案 0 :(得分:19)
我已经使用了hibernate @Index
注释,但没有任何问题,但看起来JPA @Index
注释在可以使用的地方更严格。摘自上一个问题 - The annotation @Index is disallowed for this location:
JPA索引注释只能用作
@Table
,@SecondaryTable
等其他注释的一部分。
@Table(indexes = { @Index(...) })