@OrderBy with property path does not work

Hi

I have a Report entity with a property events as a list of ReportEvent which is a link Entity between Report and Event.

Property is declared this way:

    @OrderBy("event.date")
    @OneToMany(mappedBy = "report")
    protected List<ReportEvent> events;

Issue when opening browse screen:

javax.persistence.PersistenceException: Exception [EclipseLink-6015] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.QueryException
Exception Description: Invalid query key [date] in expression.
Query: ReadAllQuery(name="events" referenceClass=ReportEvent )
FetchGroup(events){deleteTs, report => {class java.lang.Object=FetchGroup(report){deleteTs, id, title, version, deletedBy}}, id, event => {class java.lang.Object=FetchGroup(event){date, deleteTs, id, version, deletedBy}}, version, deletedBy}
---

I’m pretty sure that JPA allows it.

Sample project attached.

Regards
Michael

orderbyexpr.zip (76.8 KB)

Hello @michael.renaud

Thank you for reporting the problem. I’ve created an issue: GitHub

Regards

Hi,

Actually JPA spec does not allow it, see “11.1.42 OrderBy Annotation” section. It allows dot notation only for embedded attributes. And the same is clearly explained at the page mentioned above.

Regards,
Konstantin

My bad then, so I will have to dernomalize the date in ReportEvent, no big deal.

Michael