JavaFX BooleanProperty和休眠

我试图将JavaFX BooleanPropety添加到我的模型中,该模型由Hibernate保留,但出​​现以下错误。

Caused by: org.hibernate.MappingException: Could not determine type for: javafx.beans.property.BooleanProperty.

JavaFX StringProperty可以很好地保持持久,所以我有点困惑。

我的模型课如下

@Entity

public class Currency {

private String uuid;

private BooleanProperty isDefault = new SimpleBooleanProperty();

private StringProperty name = new SimpleStringProperty();

private StringProperty code = new SimpleStringProperty();

@Id

@GeneratedValue(generator = "uuid")

@GenericGenerator(name = "uuid", strategy = "uuid2")

@Column(name = "id")

public String getUuid() {

return uuid;

}

public void setUuid(String uuid) {

this.uuid = uuid;

}

public String getName() {

return name.get();

}

public void setName(String name) {

this.name.set(name);

}

public String getCode() {

return code.get();

}

public void setCode(String code) {

this.code.set(code);

}

public boolean getIsDefault() {

return isDefault.get();

}

public void setIsDefault(boolean isDefault) {

this.isDefault.set(isDefault);

}

public StringProperty nameProperty() {

return name;

}

public StringProperty codeProperty() {

return code;

}

public BooleanProperty isDefaultProperty(){

return isDefault;

}

}

回答:

重命名

private BooleanProperty isDefault;

private BooleanProperty default;

解决了问题。原因是在Java中,布尔字段的命名约定完全不同。在以下链接中对此进行了解释

以上是 JavaFX BooleanProperty和休眠 的全部内容, 来源链接: utcz.com/qa/422828.html

回到顶部