Hibernate 由实体类与配置文件的配置关系生成数据库中的表

import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class AutoCreateTable {

	/**
	 * @param args
	 * 该类用来创建数据库表格
	 * 运行该类的时候会根据实体类以及你配置的映射文件来生成数据库表格
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Configuration cfg = new Configuration().configure();
		SchemaExport sex = new SchemaExport(cfg);
		sex.create(true, true);
	}

}

  

原文地址:https://www.cnblogs.com/E-star/p/3394601.html