【发布时间】:2019-05-18 01:06:26
【问题描述】:
我想通过代码优先方法使用 hibernate 和 java 生成我的数据库。我已成功生成数据库,但我错过了我的迁移文件。对 .NET 中的 EntityFrameworkCore、PHP 中的 Eloquent 或节点中的 Sequelize 等迁移有休眠支持吗?
这是我生成数据库的类:
public class CreateDataBase {
public static void main(String[] args) {
Configuration conf = new Configuration();
conf.configure();
SchemaExport se = new SchemaExport(conf);
se.create(true, true);
}
}
这是我的架构:
package Infra.HibernateConfiguration;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Bank {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column()
private String code;
@Column()
private String name;
public int getId() {
return id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
【问题讨论】:
标签: java hibernate migration code-first