title: Hibernate: When to use @Index annotation
body: <p>In my scenario, I have a schema generation script to create tables and required indexes. I am wondering is there any need to define <code>@Index</code> annotation in hibernate entities as well, if so why?</p>
  
  <p><strong>Script:</strong></p>
  
  <pre><code>create table issues (id, project_id, .., status_id)
  
  create index idx_issues_projid on issues (project_id)
  </code></pre>
  
  <p><strong>Entity:</strong></p>
  
  <pre><code>@Table(name="issues")
  public class DBIssue {
  
  ..
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "PROJECT_ID")
    @Index(name="INDEX_TFW_ISSUE_PROJECT_ID")
    private DBProject project;
  }
  </code></pre>
  
  <p><strong>Hibernate configuration:</strong></p>
  
  <blockquote>
    <p><code>&lt;property name="hibernate.hbm2ddl.auto"&gt;off&lt;/property&gt;</code></p>
  </blockquote>