在使用hibernate时,可以在hibernate.cfg.xml中设置一些属性来自动生成table,也可以自己手动生成table。
自动生成table:在hibernate.cfg.xml中设置<property name = "hbm2ddl.auto">update</property>,这样在部署
项目的时候就自动生成了所有的table。
手动生成table:不在配置文件hibernate.cfg.xml中配置自动生成表的相应的配置,而是在Junit测试中写一个测试
方法来手动生成。
public void testSchemaExport ( ) {
new SchemaExport ( new AnnotationConfiguration( ).configure()) . create(true, true);
}
——空气还在,希望还在。
hibernate生成table
最新推荐文章于 2019-10-08 09:42:39 发布