1

I'm modeling an entity with hibernate. I'm using the JavaFX Property Pattern.

I'm using PROPERTY access so Hibernate is looking at my methods for configuration.

My problem is the word "Issue" starts with "is" and so it seems that Hibernate thinks my property method is a getter for a boolean—something like isOpen().

It throws the following error when I try set up a 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)

Here's a watered down version to show the problem:

@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();
    } 
}

How do I get Hibernate to stop thinking my method is a getter (besides changing the method name?)

Brad Turek
  • 2,472
  • 3
  • 30
  • 56
  • Did you test with a different name and works? – KESO Apr 05 '18 at 22:56
  • Mark it `@Transient`. – teppic Apr 05 '18 at 23:00
  • 1
    @KESO, it does work with a different name, but I'm sure you'll agree that it's important to stick to convention, if possible. – Brad Turek Apr 05 '18 at 23:11
  • @teppic, thanks, `@Transient` seems to work. If you want to leave an answer explaining why it works, maybe with some sources, I think that might be the right answer. – Brad Turek Apr 05 '18 at 23:16
  • Possible duplicate of [Why does JPA have a @Transient annotation?](https://stackoverflow.com/questions/2154622/why-does-jpa-have-a-transient-annotation) – teppic Apr 06 '18 at 00:39
  • 1
    @teppic, I don't think it's a duplicate. [_That question_](https://stackoverflow.com/questions/2154622/why-does-jpa-have-a-transient-annotation) is about the difference between Java's `transient` keyword and JPA's `@Transient` annotation. _This question_ describes a problem where `@Transient` just happens to be the solution. Would you agree? – Brad Turek Apr 06 '18 at 17:49

0 Answers0