About Question enthuware.oce-jpad.v6.2.490 :
Moderators: Site Manager, fjwalraven
About Question enthuware.oce-jpad.v6.2.490 :
I believe option A will also return what is asked in question, the difference with B that it may return some duplicated rows, but each row will correctly show name of student and numberof presentations done by this student. Question must be more explicit if no duplicate rows allowed.
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.490 :
You are right. This has been updated.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.oce-jpad.v6.2.490 :
hello,
I want to ask why select count(s.presentations) directly in option b.
Because "it is illegal to select elements directly from a collection-based relationship."
Thanks in advance
I want to ask why select count(s.presentations) directly in option b.
Because "it is illegal to select elements directly from a collection-based relationship."
Thanks in advance
-
- Posts: 2
- Joined: Tue Jun 05, 2012 8:02 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.490 :
I have the same question.hfinit wrote:hello,
I want to ask why select count(s.presentations) directly in option b.
Because "it is illegal to select elements directly from a collection-based relationship."
Thanks in advance
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.490 :
As explained in the explanation given with the question, it should be valid because presentations is an association field in student.
Paul.
HTH,As per Section 4.8.5, the path expression argument to COUNT may terminate in either a state field or a association field, or the argument to COUNT may be an identification variable. Therefore, the COUNT(s.presentations) should be valid.
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.oce-jpad.v6.2.490 :
This is very wrong ! by association field it means: single-valued association field, not collection-valued association field ! Think of it, how this could be translated to SQL ? The only two methods that would allow such a strange behavior are: SIZE and IS EMPTY which translate in the SQL with subqueries.admin wrote:As explained in the explanation given with the question, it should be valid because presentations is an association field in student.HTH,As per Section 4.8.5, the path expression argument to COUNT may terminate in either a state field or a association field, or the argument to COUNT may be an identification variable. Therefore, the COUNT(s.presentations) should be valid.
Paul.
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.490 :
This query seems to work fine on Glassfish using Hibernate as well as EclipseLink. I do not have the generated SQL query right now but you may try the sample app and see the query.Guest wrote:This is very wrong ! by association field it means: single-valued association field, not collection-valued association field ! Think of it, how this could be translated to SQL ? The only two methods that would allow such a strange behavior are: SIZE and IS EMPTY which translate in the SQL with subqueries.admin wrote:As explained in the explanation given with the question, it should be valid because presentations is an association field in student.HTH,As per Section 4.8.5, the path expression argument to COUNT may terminate in either a state field or a association field, or the argument to COUNT may be an identification variable. Therefore, the COUNT(s.presentations) should be valid.
Paul.
If the specification meant single valuated association field, it would have said so. But I will try to do more research on this and find out.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.oce-jpad.v6.2.490 :
The BNF in spec states:
Therefore I think collection is not a valid terminator in count() function by spec definition
Code: Select all
COUNT ([DISTINCT] identification_variable | state_field_path_expression | single_valued_object_path_expression)
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.490 :
Well, the BNF settles it. The option has now been changed to
thank you for your feedback!
Code: Select all
select s.firstname, count(p) from Student s join s.presentations p group by s.firstname
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 7 guests