I am interested in how hibernate.hbm2ddl.auto=validate actually works and I am struggling to find comprehensive documentation.
We\'ve recently discovered production
I'm concerned this will hit the same problem and I'm interested in finding more documentation about how this validation actually works.
In my opinion, the best documentation is the source code that you could check to see what is happening exactly. The relevant method is org.hibernate.tool.hbm2ddl.SchemaValidator#validate()
.
I went quickly through the code and I don't think that the SchemaValidator
verifies foreign keys in the database: it checks the presence of tables, columns, id generators but not foreign keys. A test against a pet database seems to confirm this behavior: dropping a FK constraint doesn't break schema validation (in other words, the validator checks if the application can run, not for referential integrity).
Now, HHH-3532 being marked as fixed, why don't you upgrade to a newer version of Hibernate or, if changing the version of Hibernate is too heavy, why don't you apply the patch for HHH-3532 yourself?
Having that all said, I don't use hibernate.hbm2ddl.auto=update
to update production databases, I use change scripts. But I use hibernate.hbm2ddl.auto=validate
and I'm happy with it.