jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
187 stars 55 forks source link

make identification variables (and the SELECT) clause optional in JPQL #588

Closed gavinking closed 3 months ago

gavinking commented 3 months ago

This is a minimal change to support the subset in Jakarta Data i.e. it is only allowed when there is just one thing in the FROM clause.

see #452

gavinking commented 3 months ago

Interesting. I came up with an alternative approach that in certain ways is even more "minimal".

We could say that whenever the identification variable is missing (in a range declaration, or in a path expression) then it is implicitly assigned the variable this.

So you could write:

select this from Entity where name like :name

And that would be equivalent to:

select this from Entity this where this.name like :name

I actually like this quite a lot. WDYT @lukasj?

gavinking commented 3 months ago

We could say that whenever the identification variable is missing (in a range declaration, or in a path expression) then it is implicitly assigned the variable this.

I pushed a second commit which shows what that would look like.

lukasj commented 3 months ago

it looks better with this, thanks!

gavinking commented 3 months ago

Awesome! 🎉🎉🎉