当前位置: 代码迷 >> 综合 >> 3.把hbm转化为DDL有两种方式:第一种是ExportDB,执行ExportDB
  详细解决方案

3.把hbm转化为DDL有两种方式:第一种是ExportDB,执行ExportDB

热度:85   发布时间:2024-01-17 02:46:13.0
package com.bjpowernode.hibernate;import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;/*** 将hbm生成ddl* @author Administrator**/
public class ExportDB {public static void main(String[] args) {//默认读取hibernate.cfg.xml文件Configuration cfg = new Configuration().configure();SchemaExport export = new SchemaExport(cfg);export.create(true, true);}
}

drop table if exists Userdrop table if exists User2create table User (id varchar(255) not null,name varchar(255),password varchar(255),createTime datetime,expireTime datetime,primary key (id))create table User2 (id varchar(255) not null auto_increment,name varchar(255),password varchar(255),createTime datetime,expireTime datetime,primary key (id))


  相关解决方案