无法在hibernate注释中添加新列来映射布尔值

时间:2015-05-11 14:46:31

标签: java spring hibernate orm annotations

@Column(columnDefinition="boolean default false")

public boolean getusernameChange() {
    return usernameChange;
}
public void setusernameChange(boolean usernameChange) {
    this.usernameChange =usernameChange;
}

上述方法是使用@Entity注释实现的。

2 个答案:

答案 0 :(得分:0)

删除旧列并使用以下@Column注释

进行更新
 @Column(name="USER_CHANGE", columnDefinition = "tinyint default false")

答案 1 :(得分:0)

尝试

@Type(type = "org.hibernate.type.NumericBooleanType")
private Boolean usernameChange = false;

public Boolean getUsernameChange() {
    return this.usernameChange;
}

public void setUsernameChange(Boolean usernameChange) {
    this.usernameChange = usernameChange;
}