下面是一個Entity
名爲Person:使用布爾值設置實體的字符串字段?
@Entity
@Table(
name = "PERSON"
)
public class Person {
//other fields etc
@Column(
name = "PAID_IN_FULL",
nullable = false
)
private String paidInFull;
public void setPaidInFull(boolean paidInFull) {
this.paidInFull = paidInFull?"Y":"N";
}
}
使用上面的二傳手,如果我要做到以下幾點:
person.setPaidInFull(true);
什麼字符串值將是其設置爲,這將是"Y"
或"N"
?
你試過了嗎? – marthursson