Reputation: 2155
I use Autogenerate DDL feature from Hibernate to create my tables and columns.
However, I end up deleting many columns in my entities but those columns remain in the database.
Is there a script that could identify those unmapped columns and tables so I could manually delete them?
Right now, I do it manually but it's becoming problematic as the database grows.
Upvotes: 1
Views: 294
Reputation: 13835
The recommended thing is:
We should use the hibernate.hbm2ddl.auto property only in the development environment, not is the production
If hibernate.hbm2ddl.auto=create-drop, hibernate will drop and create a new database every time of deployment, that means we can track the database state and its consistency.
If hibernate.hbm2ddl.auto=update, hibernate will only update the database with the changes to made in model/entity classes, but it should not be trusted for the production environment/database.
hibernate.hbm2ddl.auto should be set to default for the production environment, so that no databases changes should be reflected from hibernate in production.
Upvotes: 1
Reputation: 790
I am afraid you there is no automated way to do that.
Alternatively you can drop the whole table before building and loading the project and let hibernate re-create it with your defined column names.
Upvotes: 1