Okay, my bad on that one. My example was meant to be:
select distinct cat
from Cat cat
where cat.kittens.age > 10
That still won't work, however. Here's my actual query, just so I can't mess up another example. :D
Code:
return getHibernateTemplate().find(
"SELECT DISTINCT ep.State " +
"FROM EzProv ep " +
"WHERE ep.healthPlanJoin.healthPlan.hpcode = ?",
hpcode
);
So healthplan is joined to provider as a many to many. I need to include the join table because it contains other information that I need. Here's what Hibernate has to say:
QueryException: expecting 'elements' or 'indices' after: healthPlan