How to create indexes on multiple columns

后端 未结 3 1475
孤街浪徒
孤街浪徒 2021-01-20 16:55

We have the following entity relationships where a User belongs to a particular Organization. My queries either look like \"select * from User where org=:org\" or \"select *

3条回答
  •  孤街浪徒
    2021-01-20 17:35

    This is doable using the Hibernate specific @Table annotation. From the documentation:

    2.4.1 Entity

    ...

    @Table(appliesTo="tableName", indexes = { @Index( name="index1", columnNames={"column1", "column2"} ) } ) creates the defined indexes on the columns of table tableName. This can be applied on the primary table or any secondary table. The @Tables annotation allows your to apply indexes on different tables. This annotation is expected where @javax.persistence.Table or @javax.persistence.SecondaryTable(s) occurs.

    Reference

    • Hibernate Annotations Reference Guide
      • 2.4. Hibernate Annotation Extensions

提交回复
热议问题