Hi,
Considering the COUNT aggregate function the fourth proposition in this question (SELECT COUNT (s.presentations)...) suggests that we can uses collection_valued association path expression.
It is confirmed with Glassfish/toplink (IR). Furthermore If we read the persistence spec (JPA 1.0). p101 about COUNT, it seems to confirm this assertion : COUNT can use collection_valued association as argument, since there no detail.
But if we look at the definition of aggregate_expression in 4.4 section (BNF) or in the SELECT syntax p 99, it seems that only single_valued are permitted as association path expression. The book pro JPA 1.0 confirms this assertion. Tests with Hibernate (non IR) too.
Is there a GAP in the spec ?
So does COUNT accepts or not collection_valued association path expressions as argument ?
thanks by advance.
Best regards,
Alex
About Question com.enthuware.ets.scbcd.v5.2.128 : test 2 question 22
Moderator: admin
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scbcd.v5.2.128 : test 2 question 22
The specification explicitly states, "The path expression argument to COUNT may terminate in
either a state field or a association field".
Obviously, COUNT wouldn't make much sense for a non-collection valued association. So I would say yes, COUNT accepts collection_valued association path expressions as an argument.
Did I understand your query correctly?
either a state field or a association field".
Obviously, COUNT wouldn't make much sense for a non-collection valued association. So I would say yes, COUNT accepts collection_valued association path expressions as an argument.
Did I understand your query correctly?
Re: About Question com.enthuware.ets.scbcd.v5.2.128 : test 2 question 22
Hi,
Yes you have understood correctly my query and I agree with you for the spec. explanation (there is no detail about single-valued or collection-valued)
But what I say is that in the spec we can read too :
aggregate_expression ::=
{ AVG | MAX | MIN | SUM } ([DISTINCT] state_field_path_expression) |
COUNT ([DISTINCT] identification_variable | state_field_path_expression |
single_valued_association_path_expression)
Furthermore I don't find sample in the spec. with collection_valued associations.
And in EJB PRO JPA we can read : The count fonction take either identification variable or path expression...This path expression may resolve to state field or single valued association fields....
Regards,
Alex
Yes you have understood correctly my query and I agree with you for the spec. explanation (there is no detail about single-valued or collection-valued)
But what I say is that in the spec we can read too :
aggregate_expression ::=
{ AVG | MAX | MIN | SUM } ([DISTINCT] state_field_path_expression) |
COUNT ([DISTINCT] identification_variable | state_field_path_expression |
single_valued_association_path_expression)
Furthermore I don't find sample in the spec. with collection_valued associations.
And in EJB PRO JPA we can read : The count fonction take either identification variable or path expression...This path expression may resolve to state field or single valued association fields....
Regards,
Alex
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scbcd.v5.2.128 : test 2 question 22
It could be an oversight on the part of Specification authors to miss collection valued association_path_expression.
I think so because logically, count(s.presentations) does make sense and it should be supported.
I think so because logically, count(s.presentations) does make sense and it should be supported.
Who is online
Users browsing this forum: No registered users and 10 guests