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

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
ikotev
Posts: 17
Joined: Sat Feb 28, 2015 2:26 am
Contact:

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

Post by ikotev »

Hello,

Second answer:
select s from Student s where (select size(p) from s.presentations p) = 1
is wrong but given explanation is not correct:
size can be used only in where part. But here it is being used in select part. count can be used in the select part.
according to specification:
4.6.17.2 String, Arithmetic, and Datetime Functional Expressions
The Java Persistence query language includes the built-in functions described in subsections 4.6.17.2.1,
4.6.17.2.2, 4.6.17.2.3, which may be used in the SELECT, WHERE or HAVING clause of a query.
I think that problem is when you use SIZE in SELECT clause of sub-queries. This is correct:

SELECT SIZE(s.presentations) FROM Student s

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

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

Post by admin »

You are right, I am not sure why the explanation says that. I checked the specification but couldn't find where it says it can't be used in sub-query.

What I do see that it the definition for size given in section 4.6.17.2.2 says, "SIZE(collection_valued_path_expression)". So something like select size(s.presentations) from Students s would be valid but select size(p) from s.presentations p is not valid.

-Paul.

ikotev
Posts: 17
Joined: Sat Feb 28, 2015 2:26 am
Contact:

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

Post by ikotev »

Yes Paul correct. As you said it should be collection_valued_path_expression no matter if it is in sub-query or not. Thanks.

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

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

Post by admin »

Updated the explanation.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests