package com.hst.mapping;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
/**
* 有hibernate.hbm.xml文件时,用该方法
*/
//默认读取hibernate.cfg.xml文件
Configuration configuration = new Configuration().configure();
//生产并输出sql到当前目录和数据库。
SchemaExport schemaExport = new SchemaExport(configuration);
//创建表结构,第一个true表示在控制台打印SQL语句,第二个true表示导入sql到数据库
schemaExport.create(true, true);
/**
* 注解时用该方法自动生成数据库
*/
//AnnotationConfiguration
AnnotationConfiguration cfg=new AnnotationConfiguration().configure();
SchemaExport export=new SchemaExport(cfg);
export.create(true, true);
}
}
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
/**
* 有hibernate.hbm.xml文件时,用该方法
*/
//默认读取hibernate.cfg.xml文件
Configuration configuration = new Configuration().configure();
//生产并输出sql到当前目录和数据库。
SchemaExport schemaExport = new SchemaExport(configuration);
//创建表结构,第一个true表示在控制台打印SQL语句,第二个true表示导入sql到数据库
schemaExport.create(true, true);
/**
* 注解时用该方法自动生成数据库
*/
//AnnotationConfiguration
AnnotationConfiguration cfg=new AnnotationConfiguration().configure();
SchemaExport export=new SchemaExport(cfg);
export.create(true, true);
}
}