Hibernate custom schema creation

前端 未结 1 1856
一个人的身影
一个人的身影 2021-01-15 04:46

create creates a new database schema and update

相关标签:
1条回答
  • 2021-01-15 05:36

    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);
    
    0 讨论(0)
提交回复
热议问题