Hopefully your not still puzzled nearly 3 years on!
In your case I'd try...
Code:
SELECT count(rt.Id.SomeObj) FROM RankedTeam rt
as I'm guessing you have a RankedTeamPK class.
While trying to "group by" the "count" of total "votes" for each "person" I had the same QueryException with this incorrect query...
Code:
select person from Person person
left join person.VoteSet votes
group by person order by count(votes) desc
it worked when I modified the "count" part...
Code:
select person from Person person
left join person.VoteSet votes
group by person order by count(votes.Id.Person) desc
My mapping files and model classes are generated by Hibernate Synchronizer so in Person.hbm I have...
Code:
<set inverse="true" name="VoteSet">
<key column="personId" />
<one-to-many class="Vote" />
</set>
and in Vote.hbm I have...
Code:
<composite-id class="VotePK" name="Id">
<key-many-to-one
class="Person"
column="personId"
name="Person"
/>
<key-many-to-one
class="User"
column="userId"
name="User"
/>
</composite-id>
Because of the VotePK class it's also annoying having to do something like this in a JSP...
Code:
<c:forEach var="vote" items="${person.voteSet}" ...
${vote.id.person.id}
${vote.id.user.id}
so I add (in this case to Vote.java)...
Code:
public Long getPersonId(){
return getId().getPerson().getId();
}
public Long getUserId(){
return getId().getUser().getId();
}
so I can do...
Code:
<c:forEach var="vote" items="${person.voteSet}" ...
${vote.personId}
${vote.userId}
which feels more natural.
Anyway, hope this helps someone in the future to solve a
net.sf.hibernate.QueryException: path expression ends in a composite value:
;o)