Hibernate根据配置文件,生成建表语句

 1 import org.hibernate.cfg.Configuration;
 2 import org.hibernate.tool.hbm2ddl.SchemaExport;
 3 
 4 public class CreateHibernateSql {
 5 
 6     public static void main(String[] args) {
 7         Configuration cfg = new Configuration().configure();//默认classpath下的hibernate.cfg.xml
 8         SchemaExport export = new SchemaExport(cfg);
      //是否生成sql语句,是否建表  
9 export.create(true,false); 10 } 11 }

 

posted @ 2016-05-15 21:35  林暗草惊风丶  阅读(805)  评论(0编辑  收藏  举报