The annotation @Index is disallowed for this location

后端 未结 3 1805
陌清茗
陌清茗 2020-12-09 15:14

When trying to use the @Index annotation from javax.persistence, Eclipse gives me this error.

I\'m using it right before a java.util.

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 16:02

    If you use Eclipselink you can add this import to your class:

    import org.eclipse.persistence.annotations.Index;
    

    Then add your @Index to your field like this:

    public class FooClass {
       @Index
       int field1;
    }
    

    or

    @Index(columnNames = {"field1", "field2"})
    public class FooClass {       
       int field1;
       int field2;
    }
    

提交回复
热议问题