I am trying to validate database schema before running any queries using jdbc template. So is there any way to identify schema changes before making any queries in spring programmatically?? Currently I am using spring boot 2 and hibernate 5.
1 Answer
Add this to the configuration file.
hibernate.hbm2ddl.auto=validate
If the value is validated then hibernate only validates the table structure- whether the table and columns have existed or not. If the table doesn’t exist then hibernate throws an exception.
Validate is the default value for hbm2ddl.auto.
1 Comment
prakash pichaimuthu
This will only work if you start the application first time. I need a way to validate the schema before making query to database. Like a function will validate the schema using java.
hibernate.hbm2ddl.auto=validatein the configuration file.