@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;
}
}
posted on 2018-11-28 19:22  supress_Elon_Musk  阅读(1584)  评论(0编辑  收藏  举报