码迷,mamicode.com
首页 > 数据库 > 详细

@Column可以解决数据库字段为关键字问题

时间:2018-11-28 19:40:32      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:generated   persist   值类型   ide   imp   table   setter   tab   tun   

在下面代码中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;
}
}

@Column可以解决数据库字段为关键字问题

标签:generated   persist   值类型   ide   imp   table   setter   tab   tun   

原文地址:https://www.cnblogs.com/zxq-Study-Java/p/10034069.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!