尝试插入数据库时,我在“字段列表”中收到错误未知列客户端
我的代码显示了主键和外键
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ParamKey")
private long paramKey;
public long getParamKey() {
return paramKey;
}
@Column(name = "FeedKey")
public long getFeedKey() {
return feedKey;
}
public void setFeedKey(long feedKey) {
this.feedKey = feedKey;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "clientKey")
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
Hibernate查询如下
insert
into
M_FeedInputParams
(client, createdBy, createdTs, feedKey, jobInstanceKey, logicalDeleteTms, paramName, paramOper, paramValue, paramValueType, sourceInstanceKey, updatedBy, updatedTs)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
客户应该是clientKey
我该怎么做?
答案 0 :(得分:2)
尝试将您的getter和setter更改为:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "clientKey")
private Client clientKey;
//Getter & Setter
public Client getClientKey() {
return clientKey;
}
public void setClientKey(Client client) {
this.clientKey = client;
}
答案 1 :(得分:0)
确保client
表格中存在M_FeedInputParams
字段。
答案 2 :(得分:0)
由于列名称不同,合理列名称应与数据类型
相同,因此会出现此类问题arr = [0,0,0]
以上两个注释很重要。可以解决问题。