我一直很喜欢 Hibernate 的“yes_no”表示法。我经常在 Activity 领域使用它,如下所示:
@Column(name = "active")
@Type(type = "true_false")
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
最近我向不同的对象添加了一个名为 processable 的新字段,如下所示:
@Column(name = "processable")
@Type(type = "true_false")
public void setProcessable(boolean processable) {
this.processable = processable;
}
public boolean getProcessable() {
return processable;
}
当我编译和 hibernate 在 MySQL 中构建我的数据库时,active 仍然显示为 char,但 processable 是一个 int。我错过了什么?我对允许的 char boolean 值有多少限制?
最佳答案
我很确定注解需要在 getter 或属性本身上而不是 setter 上。
@Column(name = "processable")
@Type(type = "true_false")
public boolean getProcessable() {
return processable;
}
关于java - Hibernate boolean true_false 在 MySql 中产生一个字符......有时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2265867/