本文介绍了JavaFX BooleanProperty和Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将JavaFX BooleanPropety添加到我的模型中,该模型由Hibernate保留但我收到以下错误。

I'm trying to add JavaFX BooleanPropety to my model which is persisted by Hibernate but I'm getting the following error.

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

JavaFX StringProperty持续良好,所以我有点困惑。

JavaFX StringProperty persisting just fine so I'm confused a little bit.

我的模特类如下

@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中完全不同。以下

solves the problem. The reason is that naming convention for boolean fields is quite different in java. That's explained in the following link

这篇关于JavaFX BooleanProperty和Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 08:21