[JPA_SPEC-107] Support subqueries in SELECT lists Created: 08/Apr/15  Updated: 08/Apr/15

Status: Open
Project: jpa-spec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: dPiergies Assignee: ldemichiel
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Whilst developing applications using JPA, we have repeatedly found ourselves in a situation where the restriction preventing subqueries from being used in SELECT lists poses a serious limitation, requiring us to work around the problem in one of several ways:

1. Rearrange the query to avoid using a subquery in the SELECT list. Not a problem, but not always possible (e.g. when a count of related entities is required).

2. Issue the subselect as separate queries. Not feasible in many situations as it requires an additional database query for every row returned by the original query. This can have a huge performance impact.

3. Denormalize our database schema so that the required data can be selected from a single table. This is acceptable in some circumstances, and indeed can boost performance for some operations, but in every instance we've come across the query containing the sub-select can be executed efficiently by the database, and it seems somewhat perverse to denormalize a database schema to work around limitations in the ORM API.

4. Resort to native queries. Not pretty. Breaks type safety and can easily lead to database portability issues. Makes problems such as limiting results for pagination and allowing variable sort orders far more complex to implement.

I really do hope that the next release of the JPA specification resolves this issue, as I believe that this restriction poses a serious limitation.


Generated at Sat Jan 21 01:14:17 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.