Thank you both for trying help.
Quote:
What is expected result of this query ? "select cat from Cat cat group by cat"
I would expect the exact same as what you get from "select cat from Cat cat".
Quote:
Maybe if you show us you more complex query, we can help you out with it ;)
Ok, I'll try another example. If I showed original, it would take 3 pages to explain ;)
Objective:
Return all unique combinations of Cat and Girlfriend along with a count of how many toys are shared between the girlfriends and the kittens (for each Cat/Girlfriend combo).
This works:
Code:
select
a.id,
b.id,
count(d)
from
Cat a
left join
a.girlfriends b
left join
a.kittens c
left join
c.toys d with d in elements(b.toys)
group by
a.id,
b.id
order
by a.id,
b.id
This one gives sql error:
Code:
select
a,
b,
count(d)
from
Cat a
left join
a.girlfriends b
left join
a.kittens c
left join
c.toys d with d in elements(b.toys)
group by
a,
b
From my perspective, if the first one should work, then the second one should work as well. I try to do the second one, because I don't want just the object id's, I want the actual object. But Hibernate try to group on all of the class's columns which doesn't correlate to anything in the select list, so it fails.
I got the impression that my query should work because of the example I pointed out from the documentation. I still don't understand what is so different about mine.
I have worked around it for now by using native sql query. But I would still like to understand as I'm sure it will come up for me again.
thanks you