15

I'am trying to test JPA's @Index annotation which is avaliable since 2.1. But I can't find the documention how to use it.

When I'am trying:

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

.. then Eclipse says: "The annotation @Index is disallowed for this location"

Does anyone know how to use it? Or has found the documentation for it? :-)

Thanks for any suggestions!

Crayl
  • 1,883
  • 7
  • 27
  • 43

1 Answers1

21

I've used the hibernate @Index annotation just as you have with no issues, but it appears that the JPA @Index annotation is stricter on where it can be used. Taken from a previous question - The annotation @Index is disallowed for this location :

The JPA Index annotation can only be used as part of another annotation like @Table, @SecondaryTable, etc.

@Table(indexes = { @Index(...) }) 
Community
  • 1
  • 1
John Farrelly
  • 7,289
  • 9
  • 42
  • 52