I've added a string field to my hibernate persistent class, and restarted the application. It started SchemaUpgrade, and resulted in several errors like this one:
2011-02-03 13:04:06,522 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: alter table table_name add index FKCD10932052C35B33 (previewExample_id), add constraint FKCD10932052C35B33 foreign key (previewExample_id) references preview (id)
2011-02-03 13:04:06,522 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Can't create table 'dbName.#sql-59c_1cc' (errno: 150)
The column was added to the DB though. And everything seem to be working fine. Except fot those errors, popping out every time, I start the application.
What can I do to help it create those indexes? DB is MySQL, hibernate version is 3.0.
It doesn't sounds like a Hibernate problem. If you try to run manually, you'll see that you'll get the same problem. By looking at MySQL manuals, I see that "errno: 150" means:
If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns error number 1005 and refers to error 150 in the error message.
http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html