以"开头的Hibernate方法是",但不是getter

时间:2018-04-05 22:15:28

标签: java hibernate hibernate-mapping getter

我用hibernate建模实体。我正在使用JavaFX Property Pattern

我使用PROPERTY访问权限,因此Hibernate正在查看我的配置方法。

我的问题是"问题"从"开头是"所以似乎Hibernate认为我的属性方法是一个布尔的getter,比如isOpen()

当我尝试设置SessionFactory

时,它会抛出以下错误
java.lang.ExceptionInInitializerError
Caused by: org.hibernate.MappingException: Could not determine type for: javafx.beans.property.ObjectProperty, at table: Remediations, for columns: [org.hibernate.mapping.Column(sueDetailProperty)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:456)
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:423)
    at org.hibernate.mapping.Property.isValid(Property.java:226)
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:597)
    at org.hibernate.mapping.RootClass.validate(RootClass.java:265)
    at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:459)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
    at TestManyToManyWithExtraColumns.setUpSessionFactory(TestManyToManyWithExtraColumns.java:106)
    at TestManyToManyWithExtraColumns.<clinit>(TestManyToManyWithExtraColumns.java:16)

这是一个用于显示问题的淡化版本:

@Entity
@Access(AccessType.PROPERTY)
public class MyEntity{
    ...

    @Column(name = "detail_id")
    public IssueDetail getIssueDetail() {
        return issueDetail.get();
    }

    public void setIssueDetail(IssueDetail issueDetail) {
        this.issueDetail.set(issueDetail);
    }

    // throws error:
    // "Could not determine type for: javafx.beans.property.ObjectProperty,
    // at table: Remediations, for columns: [org.hibernate.mapping.Column(sueDetailProperty)]"
                                         |
    public ObjectProperty<IssueDetail> issueDetailProperty() {
        return issueDetail.getOrCreateProperty();
    } 
}

如何让Hibernate停止认为我的方法是一个getter(除了更改方法名称?)

0 个答案:

没有答案