jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
203 stars 59 forks source link

Extend specialized expression types with convenience methods #530

Open beikov opened 1 year ago

beikov commented 1 year ago

After https://github.com/jakartaee/persistence/issues/519 is done, we should consider some convenience methods which we could implement through default methods in terms of existing functions. I would propose the following:

We could also consider the following additions which I think improve readability:

I prefer to write and read expr.gtAll(subquery) over expr.gt(subquery.all()) or expr.gt(cb.all(subquery)). Thinking about this a bit more, we could even drop the all(), any() and some() methods in Subquery which I added as part of https://github.com/jakartaee/persistence/issues/519 in favor of the listed methods. AFAIK, there is no other valid use for the subquery quantifiers than with the relational comparison operators.

Some of the proposals are inspired by https://github.com/querydsl/querydsl/blob/master/querydsl-core/src/main/java/com/querydsl/core/types/dsl/StringExpression.java etc.