use DISTINCT ON Ejb-QL
is it possible to use PostgreSQL-like DISTINCT ON in EJB using named query?
o.fromDate,o.empLeaveMasterId,o.employeeInfoId, o.leavePurposeId ,o.toDate,o.createdByUserId,o.createDate,o.lastModifiedUserId,o.lastModifiedDate,o.isSystemRecord
The field describe above is m开发者_开发技巧y entity bean field and I want to get fromDate wise distinct record
Is it possible using namedquery ?
I don't see how this could be possible: JPQL offers a language that can be translated into SQL for any database, this obviously excludes database specific keywords.
My suggestion would be to use GROUP BY
and subqueries instead, as suggested in the PostgreSQL documentation:
The
DISTINCT ON
clause is not part of the SQL standard and is sometimes considered bad style because of the potentially indeterminate nature of its results. With judicious use ofGROUP BY
and subqueries inFROM
the construct can be avoided, but it is often the most convenient alternative.
Or use a native query if portability is not a concern.
精彩评论