Skip to main content

[jpa-spec users] Reason for limiting select clause to single-valued expression?

  • From: <arjan.tijms@...>
  • To: users@...
  • Subject: [jpa-spec users] Reason for limiting select clause to single-valued expression?
  • Date: Mon, 6 Jan 2014 23:25:00 +0000 (UTC)

Hi,

Section 4.8 of the JPA spec defines that a select expression is limited
to a single valued path expression. This is emphasized in the body text
of this section via the following paragraph:

"Note that the SELECT clause must be specified to return only
single-valued expressions. The query below is therefore not valid:

SELECT o.lineItems FROM Order AS o"

I wonder what the reason for this limitation is.

In practice I found this to be quite a limitation when needing to
create e.g. DTOs from an entity.

The effect of selecting a single collection attribute from an entity
can be mimicked by something like

SELECT o.id, lineItem FROM Order AS o join o.lineItems as lineItem

And then aggregating the result manually in Java code. 

If this can be done rather easily (but tediously) with manual code, why
shouldn't the persistence provider be able to do this?


[jpa-spec users] Reason for limiting select clause to single-valued expression?

arjan.tijms 01/06/2014

[jpa-spec users] Re: Reason for limiting select clause to single-valued expression?

Kevin Sutter 01/07/2014

[jpa-spec users] Re: Reason for limiting select clause to single-valued expression?

arjan tijms 01/07/2014

[jpa-spec users] Re: Reason for limiting select clause to single-valued expression?

Linda DeMichiel 01/08/2014

[jpa-spec users] Re: Reason for limiting select clause to single-valued expression?

arjan tijms 01/09/2014

[jpa-spec users] Re: Reason for limiting select clause to single-valued expression?

Linda DeMichiel 01/10/2014
 
 
Close
loading
Please Confirm
Close