[Hibernate 3] Index not created by SchemaUpdate

A normal index like the one below won't get created automatically if hibernate.hbm2ddl.auto is set to update.

<property 
    name="idA" 
    index="idx_id_a" 
    not-null="true" 
    type="long" 
    column="..."/> 


If the property is a primary key or it's unique, the index will be created, however. It's a hibernate bug reported here: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1012.

A simple solution will be creating the index locally and migrating the creation script to the live system. If you opt for hibernate.hbm2ddl.auto = create, all data need to be backed up as this option clears the database before reconstructing the whole schema.

你可能感兴趣的:(Hibernate,xml,UP,OpenSource)