Hibernate控制台显示创建数据库表语句

 1 package cqvie.yjq.View;
 2 
 3 import org.hibernate.Session;
 4 import org.hibernate.Transaction;
 5 import org.hibernate.cfg.AnnotationConfiguration;
 6 import org.hibernate.tool.hbm2ddl.SchemaExport;
 7 
 8 public class Test {
 9 
10     public static void main(String[] args) {
11     
12         //调用建表语句
13         exportDDL();
14         
15     }
16 
17     //建表语句
18     public static void exportDDL() {  
19         Configuration configuration = new AnnotationConfiguration().configure();   
20         SchemaExport sexport = new SchemaExport(configuration);  
21         sexport.setFormat(true);//格式化输出  
22           sexport.setDelimiter(";");      //每句sql都以;结尾  不然导入sql的时候会出现错误  
23         sexport.setOutputFile("D:\\auto.sql");  
24         sexport.create(true, true);  
25     }  
26 }

 

posted @ 2016-11-30 21:33  走在一线的码农  阅读(725)  评论(1编辑  收藏  举报