gpt4 book ai didi

hibernate - JavaFX BooleanProperty 和 Hibernate

转载 作者:行者123 更新时间:2023-12-02 12:38:14 26 4
gpt4 key购买 nike

我正在尝试将 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 中 bool 字段的命名约定有很大不同。下面对此进行了解释 link

关于hibernate - JavaFX BooleanProperty 和 Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27979073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com