Hibernate: when to use @Index annotation

In my script, I have a script schema generation for creating tables and required indexes. I wonder if there is a need to define annotations @Indexin sleep mode objects, if so, why?

Script:

create table issues (id, project_id, .., status_id)

create index idx_issues_projid on issues (project_id)

Entity:

@Table(name="issues")
public class DBIssue {

..
  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "PROJECT_ID")
  @Index(name="INDEX_TFW_ISSUE_PROJECT_ID")
  private DBProject project;
}

Sleep Mode Configuration:

<property name="hibernate.hbm2ddl.auto">off</property>

+4
source share
1 answer

, Hibernate @Index, JPA 2.1. @Index , , , , , . , , , , " DBIssue, DBProject, , DBIssue.

+6

All Articles