JPA查询ManyToOne Exception

时间:2017-09-24 17:44:20

标签: jpa eclipselink jpql

我有以下实体类(摘录):

@NamedQueries({@NamedQuery(name = "Orphans.findAll", query = "SELECT c FROM ReferencePeak c WHERE c.libraryPeak IS EMPTY")})
@Access(AccessType.PROPERTY)
@Entity(name = "ReferencePeak")
public class ReferencePeakEntity extends PeakEntity {

    private final ObjectProperty<LibraryPeakEntity> libraryPeak = new SimpleObjectProperty<>();

    private final ObjectProperty<SampleEntity> sample = new SimpleObjectProperty<>();

    public ReferencePeakEntity() {

    }   

    @ManyToOne(targetEntity = LibraryPeakEntity.class)
    public final LibraryPeakEntity getLibraryPeak() {
    return this.libraryPeakProperty().get();
    }

    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
    public final SampleEntity getSample() {
    return this.sampleProperty().get();
    }

    public final ObjectProperty<LibraryPeakEntity> libraryPeakProperty() {
    return this.libraryPeak;
    }

    public final void setLibraryPeak(final LibraryPeakEntity libraryPeak) {
    this.libraryPeakProperty().set(libraryPeak);
    }

    public final ObjectProperty<SubstanceEntity> substanceProperty() {
    return this.substance;
    }

    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
    public final SubstanceEntity getSubstance() {
    return this.substanceProperty().get();
    }


    public final void setSubstance(final SubstanceEntity substance) {
    this.substanceProperty().set(substance);
    }

}

命名查询“Orphans.findAll”抛出以下异常:

“集合值路径'c.libraryPeak'必须解析为关联字段。”

我想查询所有没有任何'libraryPeak'设置的实体,即getLibraryPeak()将返回null

0 个答案:

没有答案