hibernate 中常用到自动生成数据表代码
01
package opg;
02
03
import org.hibernate.cfg.Configuration;
04
import org.hibernate.tool.hbm2ddl.SchemaExport;
05
06
public class CreateTable {
07
08
/**
09
* @param args
10
*/
11
public static void main(String[] args) {
12
Configuration cfg=new Configuration().configure();
13
SchemaExport se=new SchemaExport(cfg);
14
se.create(true, true);
15
16
}
17
18
}
注:
如果在 hibernate 自动生成表时,不删除现有的表 可以在hibernate 中配置:
1
<prop key="hibernate.hbm2ddl.auto">update</prop>
补充:软件开发 , Java ,