About Question enthuware.oce-jpad.v6.2.490 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

About Question enthuware.oce-jpad.v6.2.490 :

Post by ETS User »

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.

admin
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by admin »

You are right. This has been updated.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

hfinit

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by hfinit »

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

hebolive
Posts: 2
Joined: Tue Jun 05, 2012 8:02 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by hebolive »

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
I have the same question.

admin
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by admin »

As explained in the explanation given with the question, it should be valid because presentations is an association field in student.
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Guest

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by Guest »

admin wrote:As explained in the explanation given with the question, it should be valid because presentations is an association field in student.
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.
HTH,
Paul.
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
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by admin »

Guest wrote:
admin wrote:As explained in the explanation given with the question, it should be valid because presentations is an association field in student.
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.
HTH,
Paul.
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.
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.
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.

heaven

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by heaven »

The BNF in spec states:

Code: Select all

COUNT ([DISTINCT] identification_variable | state_field_path_expression | single_valued_object_path_expression)
Therefore I think collection is not a valid terminator in count() function by spec definition

admin
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.490 :

Post by admin »

Well, the BNF settles it. The option has now been changed to

Code: Select all

select s.firstname, count(p) from Student s join s.presentations p group by s.firstname
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 73 guests