【问题标题】:How does the @Index annotation work in JPA 2.1? [duplicate]@Index 注释在 JPA 2.1 中如何工作? [复制]
【发布时间】:2013-11-02 22:25:56
【问题描述】:

我正在尝试测试自 2.1 以来可用的 JPA 的 @Index 注释。但我找不到如何使用它的文档。

当我尝试时:

@Index(columnList = "firstName")
private String firstName;

.. 然后 Eclipse 说:“该位置不允许使用注释 @Index”

有人知道怎么用吗?或者找到了它的文档? :-)

感谢您的任何建议!

【问题讨论】:

    标签: java hibernate jpa


    【解决方案1】:

    我已经使用了 hibernate @Index 注释,就像你没有问题一样,但是 JPA @Index 注释似乎更严格地限制了它的使用位置。取自上一个问题 - The annotation @Index is disallowed for this location

    JPA 索引注解只能用作另一个注解的一部分,例如 @Table@SecondaryTable 等。

    @Table(indexes = { @Index(...) }) 
    

    【讨论】:

      猜你喜欢
      • 2011-02-05
      • 2015-08-26
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 1970-01-01
      相关资源
      最近更新 更多