2

In JPA you can create indexes using annotations, for example as follows:

@Entity(name = "dummyEntity")
@Table( name = "dummyTable",
        indexes = {@Index(name = "indexName", columnList = "name")})
public class MyEntityObject {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long id;

    private String name;
    private String state;

    public MyEntitiyObject() {
    }
}

How can I add 'state' as an included column to this index, using JPA annotations? Or in another way so I can just roll-out my code without having to add the indexes manually.

Thank you.

Sigi
  • 59
  • 6
  • There are many duplicates for this query. http://stackoverflow.com/questions/2182950/how-to-define-index-by-several-columns-in-hibernate-entity http://stackoverflow.com/questions/3725545/how-to-create-indexes-on-multiple-columns – Kamal Kunjapur Oct 19 '16 at 13:50
  • 1
    @Kamal This one is different. OP wants to generate index on `name` with `state` as [included column](https://msdn.microsoft.com/en-us/library/ms190806.aspx) – default locale Oct 19 '16 at 13:55
  • Yup am aware of that, I went through the first link I have mentioned, there is an answer for that as well. – Kamal Kunjapur Oct 19 '16 at 14:03
  • Thank you for the link @Kamal . But I don't find an answer for included columns in there? – Sigi Oct 20 '16 at 06:24
  • @kamal I couldn't find the answer as well, perhaps you could guide us? – SatA Aug 12 '19 at 12:46
  • 6 years later, here I am also wondering this question – itsmarziparzi Apr 02 '23 at 12:19

0 Answers0