About Question enthuware.oce-jpad.v6.2.492 :
Moderators: Site Manager, fjwalraven
About Question enthuware.oce-jpad.v6.2.492 :
I need somebody to confirm that answer D is legitimate.
select count(s.presentations) from Student s
(Assume that presentations is a Collection field in Student)
If s.presentations is collection, you can't put use it as an argument for count operation, you'd have to join first with presentation, like so:
select count (p)
from Student s left join s.presentations p
select count(s.presentations) from Student s
(Assume that presentations is a Collection field in Student)
If s.presentations is collection, you can't put use it as an argument for count operation, you'd have to join first with presentation, like so:
select count (p)
from Student s left join s.presentations p
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.492 :
count(s.presentations) is valid even without a join. You may want to run the sample application verify this. You can get the sample application from: http://enthuware.com/index.php/mock-exa ... oce-jpa/85
HTH,
Paul.
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.492 :
I rechecked using your test application and I still don't see how it can work. It fails in the test application also:admin wrote:count(s.presentations) is valid even without a join. You may want to run the sample application verify this. You can get the sample application from: http://enthuware.com/index.php/mock-exa ... oce-jpa/85
HTH,
Paul.
Code: Select all
select count(p) from Student s join s.presentations p
Code: Select all
JPA Query Output -
[ArrayList Size=1
[Long : 5]
]
Code: Select all
select count(s.presentations) from Student s
Code: Select all
Exception :org.hibernate.exception.SQLGrammarException: Syntax error: Encountered "." at line 1, column 14.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.492 :
May be I am misinterpreting something but as per section 4.8.5:
But you are right it doesn't work in the test application either.
I am really sorry about the wrong information.
-Paul.
In this case, s.presentation is an association field, so it should work.For all aggregate functions except COUNT, the path expression that is the argument to the aggregate
function must terminate in a state field. 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.
But you are right it doesn't work in the test application either.
I am really sorry about the wrong information.
-Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.oce-jpad.v6.2.492 :
size would work instead of count
Re: About Question enthuware.oce-jpad.v6.2.492 :
a association field may be single-valued or collection-valued. So it's single-valued (a single entity).
You can't put max(someEntity).
It doesn't work with collections The only 2 functions/expressions that work with collection-valued associations are: SIZE & IS EMPTY, which will generate subqueries, which might be confusing, I don't understand why they even put these 2.
Cheers.
You can't put max(someEntity).
It doesn't work with collections The only 2 functions/expressions that work with collection-valued associations are: SIZE & IS EMPTY, which will generate subqueries, which might be confusing, I don't understand why they even put these 2.
Cheers.
-
- Posts: 1
- Joined: Thu Nov 20, 2014 3:55 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.492 :
According the discuss above, it seems like the option D is correct.
I have written codes to confirm that count() with collection field is valid.
I thought the correct answer will be 4 options.
Would anyone tell me why option D is not included in the correct answer?
Thanks.
I have written codes to confirm that count() with collection field is valid.
I thought the correct answer will be 4 options.
Would anyone tell me why option D is not included in the correct answer?
Thanks.
-
- Posts: 17
- Joined: Sat Feb 28, 2015 2:26 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.492 :
Hello I also can confirm written above. Will someone update the question bank and include answer D as correct.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.492 :
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.
Who is online
Users browsing this forum: No registered users and 26 guests