在服务器启动时,hibernate通过添加新列

时间:2016-04-22 06:29:35

标签: java hibernate jpa persistence hbm2ddl

在服务器启动时,hibernate通过添加新列来改变表。当它在控制台中打印时,"架构更新完成"桌子被改变了。!

我有一个表格,其中包含少量数字类型的字段。但是当我从eclipse启动我的tomcat时,hibernate通过添加同名数据类型float的新列来改变我的表。

这个

背后的根本原因是什么?
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "EPAMRT_BUC_COSTS_ARRAY") 
public class EPAMRTBucCostArray {

@Id
@GeneratedValue
private Integer BUC_COSTS_ARRAY_ID;
@Column(name= "BUC_CODE")
private String BUC_CODE;  
@Column(name= "BUC_DESC")
private String BUC_DESC;   
@Column(name= "BUC_AMOUNT")
private BigDecimal BUC_AMOUNT;  
@Column(name= "MTD_BUC")
private BigDecimal MTD_BUC;   
@Column(name= "YTD_BUC")
private BigDecimal YTD_BUC;  
@Column(name= "UNAMRT_BUC")
private BigDecimal UNAMRT_BUC;

public Integer getBUC_COSTS_ARRAY_ID() {
    return BUC_COSTS_ARRAY_ID;
}
public void setBUC_COSTS_ARRAY_ID(Integer bUC_COSTS_ARRAY_ID) {
    BUC_COSTS_ARRAY_ID = bUC_COSTS_ARRAY_ID;
}
public String getBUC_CODE() {
    return BUC_CODE;
}
public void setBUC_CODE(String bUC_CODE) {
    BUC_CODE = bUC_CODE;
}
public String getBUC_DESC() {
    return BUC_DESC;
}
public void setBUC_DESC(String bUC_DESC) {
    BUC_DESC = bUC_DESC;
}

public BigDecimal getBUC_AMOUNT() {
    return BUC_AMOUNT;
}
public void setBUC_AMOUNT(BigDecimal bUC_AMOUNT) {
    BUC_AMOUNT = bUC_AMOUNT;
}
public BigDecimal getMTD_BUC() {
    return MTD_BUC;
}
public void setMTD_BUC(BigDecimal mTD_BUC) {
    MTD_BUC = mTD_BUC;
}
public BigDecimal getYTD_BUC() {
    return YTD_BUC;
}
public void setYTD_BUC(BigDecimal yTD_BUC) {
    YTD_BUC = yTD_BUC;
}
public BigDecimal getUNAMRT_BUC() {
    return UNAMRT_BUC;
}
public void setUNAMRT_BUC(BigDecimal uNAMRT_BUC) {
    UNAMRT_BUC = uNAMRT_BUC;
}
}

架构更新完成后,有4列要添加的是MTD_BUC,YTD_BUC,UNAMRT_BUC和BUC_DESC

之前我的表是:

  • BUC_COSTS_ARRAY_ID NUMBER(22,0),
  • BUC_CODE VARCHAR2(10),
  • BUC_DESC VARCHAR2(30),
  • BUC_AMOUNT NUMBER(22,0),
  • MTD_BUC NUMBER(22,0),
  • YTD_BUC NUMBER(22,0),
  • UNAMRT_BUC号码(22,0)

由hibernate修改:

  • BUC_COSTS_ARRAY_ID NUMBER(22,0),
  • BUC_CODE VARCHAR2(10),
  • BUC_DESC VARCHAR2(30),
  • BUC_AMOUNT NUMBER(22,0),
  • MTD_BUC NUMBER(22,0),
  • YTD_BUC NUMBER(22,0),
  • UNAMRT_BUC号码(22,0)
  • BUC_DESC VARCHAR2(255),
  • MTD_BUC NUMBER(19,2),
  • UNAMRT_BUC NUMBER(19,2),
  • YTD_BUC NUMBER(19,2)

0 个答案:

没有答案