Beginner |
|
Joined: Tue Aug 26, 2003 11:33 pm Posts: 38
|
I have a class Department which is mapped to table department.
class Department {
private long id;
private String name;
private Department parentDept;
private Set subDepts;
}
Department may has zero or one parent department and zero or more sub-departments which are also of Department type. I wanna get the following information, but don't know how to write such kind of HQL. Any help is appreciated !
(1) get all the departments which don't have any sub-department.
from hibernate.Department dept where count(elements(dept.subDepts))=0
(2) get all the departments which don't have parent department.
from hibernate.Department dept where dept.parentDept is null
The (1) hql doesn't work ! It reports "Syntax error or access violation, message from server: "You have an error in your SQL syntax. "
|
|