views:

246

answers:

2

Hi All.

It's well known fact that hibernate work with indexes in a very strange way. It generate them only if you create a database schema from the scratch. But if you try to update the database schema hibernate will ignore new indexes.

My question is, does anybody find a solution how to ask hibernate generate SQL for new indexes during schema update.

UPDATE: I'll disagree with Stefan Steinegger. Index management with hibernate it's a pain. Nice to see that the feature was scheduled for next release (3.5.x) and will be backward compatible to 3.3.x and 3.2.x as well. Details are here.

+2  A: 

Schema update is not intended to be used in a production environment. It should only be used for developers.

Schema export on the other hand is recommendable to be used in production. Export the schema to get the actual schema definition and use other means to update existing databases. Write your own update scripts or use a designated tool.

Stefan Steinegger
+1. For the "designated tool" in question I highly recommend LiquiBase (http://www.liquibase.org/). It even integrates with Hibernate so the manual step of exporting the schema is unnecessary.
ChssPly76
A: 

The issue resolved in Hibernate 3.5.0-Beta-2 release. Details are here and here.

FoxyBOA