开发者

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 of GROUP BY and subqueries in FROM the construct can be avoided, but it is often the most convenient alternative.

Or use a native query if portability is not a concern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜