Closed gavinking closed 3 months ago
As a result of activity in Jakarta Data, this is now a much higher priority than I previously rated it.
@lukasj let's chat about this one soon.
Summary of current proposal:
FROM
element and no JOIN
s, the identification variable is optional and defaults to this
.SELECT
clause becomes optional, and defaults to SELECT this
.this.
.Thus, the query:
from Book where title like :title
Is equivalent to:
select this from Book as this where this.title like :title
This significantly streamlines the syntax of simple queries, without doing violence to the semantics of JPQL.
I propose that we bless queries like this one:
This is something that SQL lets you do, of course.
Hibernate has tolerated stuff like this for quite a long time, and now supports it robustly. I would be surprised if other providers don't also allow it. (But I don't know if EclipseLink supports it.)
Of course, we would probably want to impose some restrictions on this. It's most useful when there's only one entity in the query, and therefore no risk of field name collision, so the "minimal" functionality would be to allow it only in that case.
This isn't a super-high priority, but it would be a good way to improve portability of queries between providers.