How can I ask Hibernate to create an index on a foreign key (JoinColumn)?

Posted by Kent Chen on Stack Overflow See other posts from Stack Overflow or by Kent Chen
Published on 2010-03-25T05:58:18Z Indexed on 2010/03/25 6:03 UTC
Read the original article Hit count: 161

Filed under:
|
|

Hi, This is my model.

class User{

   @CollectionOfElements 
    @JoinTable(name = "user_type", joinColumns = @JoinColumn(name = "user_id"))
    @Column(name = "type", nullable = false)
  private List<String> types = new ArrayList<String>();

}

You can imagin there would be a table called "user_type", which has two columns, one is "user_id", the other is "type".

And when I use hbm2ddl to generate the ddls, I can have this table, along with the foreign key constraint on "user_id". However, there is no index of this for this column. And I need this index. How can I let hibernate to generate this index for me?

Thank you!

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about index