creates a new database schema and
You could disable the hibernate.hbm2ddl.auto
option, check the conditions (probably using plain JDBC) and call (or don't) the create method of the SchemaExport class. This would be done in your application's initialization code (a ServletContextListener
in case you are working with a web app).
An example on how to use the SchemaExport
class:
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(info.ems.models.User.class);
config.addAnnotatedClass(info.ems.models.Role.class);
config.configure();
new SchemaExport(config).create(true, true);