I have a very used project that I am currently working on. There are several places where this project can be installed, and in the future it is not known which version is used there and for which version can be updated in the future. Now they are all the same.
My problem is that there can be many changes to the hibernation entity classes, and they can easily be updated to a newer version without any problems, as well as without losing the contents of the database. Just replace the WAR and start, and it should migrate itself.
As far as I know, Hibernate does not change tables if hibernate.hbm2ddl.auto = create, but which actually throws all the data?
So, right now, when the Spring context is fully loaded, it executes a bean that will transfer the database to the current version, switching all the changes from version X to version Y (which version that was previously saved to the database) and manually change the table.
Not too much trouble doing a few hard-coded ALTER TABLEs to add a few columns, but when it comes to adding complete new tables, it’s silly to write all this ...
So my question (s) ::
Is there a way to send an entity class and dialect to Hibernate code somewhere and return a valid SQL query to create the table?
And even better, somehow create an SQL row to add a column to the table, based on the dialect?
Hope this is not a stupid question, and I haven't missed anything obvious when it comes to Hibernate ...