3

尝试插入数据库时​​,我在“字段列表”中收到错误未知列客户端

这是我的代码显示主键和外键

@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;
    }

休眠查询如下

insert 
        into
            M_FeedInputParams
            (client, createdBy, createdTs, feedKey, jobInstanceKey, logicalDeleteTms, paramName, paramOper, paramValue, paramValueType, sourceInstanceKey, updatedBy, updatedTs) 
        values
            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

客户端应该clientKey怎么办?

4

3 回答 3

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;
}
于 2013-05-27T09:54:39.960 回答
0

确保该client字段存在于M_FeedInputParams表中。

于 2013-05-27T09:54:46.213 回答
0

出现此类问题是由于列名不同,有理列名应与数据类型相同

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "addres_id")
private Address studentAddress;
public  StudentMany(){}

以上两个注释很重要。让它像你的问题一样可以解决。

于 2015-04-23T09:30:30.627 回答