jakartaee / persistence

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

consider deprecating CriteriaQuery.multiselect() #516

Closed gavinking closed 1 year ago

gavinking commented 1 year ago

The multiselect() method is not typesafe, so it's better to write:

query.select(builder.array(book.get(Book_.title), book.get(Book_.isbn));

Than:

query.multiselect(book.get(Book_.title), book.get(Book_.isbn));

Yeah, yeah, OK, so the second version saves some tokens in an already-verbose API.

But, I mean, even so, just look at the Javadoc of that method, which has to explicitly enumerate all the well-typed cases. That's a smell worse than volcanic hot springs.

So I would deprecate CriteriaQuery.multiselect, and point to CriteriaBuulder.array as the replacement.

If you guys hate that idea, I would at least add some Javadoc warning users away from from multiselect, and pointing them to the alternative.

P.S. While we're here, I would suggest adding an overloads of CriteriaBuilder.array() and CriteriaBuilder.tuple() which accept List instead of varargs, similar to what we did in #137.