1. 程式人生 > >@Column可以解決資料庫欄位為關鍵字問題

@Column可以解決資料庫欄位為關鍵字問題

在下面程式碼中numeric欄位是資料庫中的數值型別的關鍵字,只有加上@Column之後才不會報錯

import javax.persistence.*;

@Table(name = "tb_spec_param")
public class SpecParam {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Long cid;
private Long groupId;
private String name;
@Column(name = "`numeric`")
private Boolean numeric;
private String unit;
private Boolean generic;
private Boolean searching;
private String segments;

// getter和setter ...

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getCid() {
return cid;
}

public void setCid(Long cid) {
this.cid = cid;
}

public Long getGroupId() {
return groupId;
}

public void setGroupId(Long groupId) {
this.groupId = groupId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Boolean getNumeric() {
return numeric;
}

public void setNumeric(Boolean numeric) {
this.numeric = numeric;
}

public String getUnit() {
return unit;
}

public void setUnit(String unit) {
this.unit = unit;
}

public Boolean getGeneric() {
return generic;
}

public void setGeneric(Boolean generic) {
this.generic = generic;
}

public Boolean getSearching() {
return searching;
}

public void setSearching(Boolean searching) {
this.searching = searching;
}

public String getSegments() {
return segments;
}

public void setSegments(String segments) {
this.segments = segments;
}
}