JPA: Implement JPA 2.0 INDEX(collectionelement) function
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
For ordered collections, JPA 2.0 supports an INDEX function, which returns the position of the element in the list. Its support is, however, currently unavailable in QueryDSL.
In addition, currently, ListPath.
Here are the proposed semantics.
1. Under JPA, evaluation of ListPath<T, Q>.get(EXPR):
- returns a new Q with an automatically generated alias name;
- the returned entity path is added to the query's FROM clause via LEFT JOIN <path dot notation> <autogenerated alias>;
- INDEX(<
2. For more flexibility, QueryDSL can optionally support an indexOf operation of the following signature:
NumberPath<Integer> ListPath<T, Q>indexOf(Q path);
When this expression is evaluated:
- Q is added as an alias for this list path via LEFT JOIN, if it is not already there;
- The returned number path is aliased to INDEX(Q).
NumberPath<Integer> ListPath<T, Q>indexOf(T entity);
When this expression is evaluated:
- A new entity path is created with an autogenerated alias and added to LEFT JOIN.
- The returned number path is aliased to INDEX(<new path>).
- <new path> = T is added to the query's WHERE clause.
Changed in querydsl: | |
status: | New → In Progress |
Thanks for the detailed bug report. I will try to make indexed list access available also for other JPA providers. The current syntax is not JPA standard compliant, as you pointed out.