I'm trying to do some simple reporting queries. I can get something to work in SQL quite easily - but in HQL there is one problem I am having with getting a distinct pair of values.
Code:
select count (distinct person, incident) from Incident as incident join incident.person as person
What I'm more interested in is something like this:
Code:
select count (distinct person, Month(incident.date)) from Incident as incident join incident.person as person
Even something as painfully simple as this
wont work:
Code:
select distinct (person, incident) from Incident incident join incident.person
By not work, I mean I get these kind of errors (and no generated SQL - since it pukes on the query itself):
Code:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: {vector} [select distinct (person, incident) from com.foo.Incident incident join incident.person ]
The inability to make the distinct work the way it works in SQL (i.e. allow you to specify multiple things you want to be distinct) is making this basic reporting rather difficult.
Is it a synatx issue? is there some other way to do this? If it cant be done in HQL, can it be done in a criteria query?
Hibernate version:
3.3.1 GA
Name and version of the database you are using:
MySQL 5.1