Can anyone help me how can I refresh/update existing, and running hibernate/Spring application to a newer version?
To changethe source override the war in tomcat.
In Hibernate persistence.xml hibernate.hbm2ddl.auto = check – and this not refresh the db structure, only check.
My problem is in database. In the second version of the app I got much more different entity/table strucutre.
How can I upgrade the existing structure and data to the other?
Write SQL scripts, and exec it in database directly?
Is it any method for table upgradeing in java/hibernate?
Thanks
When you work with Hibernate, you can leverage hbm2ddl set in update or create, but this doesn’t suite in real cases because Hibernate can’t update your database as you want. For instance it can add column, but not remove or rename, so it’s pretty limited, and in real life you’ll probably need much more sophisticated cases when you issue a new version of your application.
In order to do it correctly, you’ll need to use special tools for database migrations like flyway or liquibase. You’ll need to setup your spring beans to initialize some class from these tools and specify your SQL scripts location, they will pick those SQL files and update database with those that are not there yet (so they won’t re-write the same scripts twice).