Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API improvements - pass List to where #137

Closed
lukasj opened this issue Oct 26, 2016 · 6 comments · Fixed by #442
Closed

API improvements - pass List to where #137

lukasj opened this issue Oct 26, 2016 · 6 comments · Fixed by #442

Comments

@lukasj
Copy link
Contributor

lukasj commented Oct 26, 2016

Quite happy to see jpa 2.1 is near...

I couldn't seem to subscribe to the mailing list, so here are some comments.

Some minor question/suggestion, maybe already discussed?

Why do we have this:

CriteriaQuery<T> where(Predicate... restrictions);

But not, additionnally, this:

CriteriaQuery<T> where(List<Predicate> restrictions);

While there is:

CriteriaQuery<T> groupBy(Expression<?>... grouping);

and

CriteriaQuery<T> groupBy(List<Expression<?>> grouping);

And List parameters for having, orderBy, ...

@lukasj
Copy link
Contributor Author

lukasj commented Oct 26, 2016

@glassfishrobot Commented
Reported by ymajoros

@lukasj
Copy link
Contributor Author

lukasj commented Oct 26, 2016

@glassfishrobot Commented
Issue-Links:
clones
JPA_SPEC-44

@lukasj
Copy link
Contributor Author

lukasj commented Oct 26, 2016

@glassfishrobot Commented
ymajoros said:
Just cloned this issue, because:

  • JPA 2.1 is done but this would still improve the API
  • JPA 2.2 is in the air
  • As I understand it, Java 8 will be required in JPA 2.2, so it's now quite trivial to add a few default methods in EntityManager interface.

Why do we need this?

I typically have a bunch of optional search queries, which I transform into predicated:

if (namePrefix != null) {
   Predicate namePredicate = ...
   predicates.add(namePredicate);
}

// boiler-plate Predicate[] predicateArray = predicates.toArray(new Predicate[0]);
query.where(predicateArray);

I'd like to just be able to to this:

query.where(predicates);

Same for CriteriaBuilder::and (and ::or, etc.), which only accept arrays. I suggest adding a Collection parameter to them.

This makes the Criteria API really dynamic (arrays aren't).

@lukasj
Copy link
Contributor Author

lukasj commented May 5, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA JPA_SPEC-137

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

@gavinking
Copy link
Contributor

Proposed solution is #442.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants