Hi,
I am studing the persistence frameworks JDO and Hibernate. Acutally, I have used Hibernate in 2 projects. For JDO, I do not use it in real project yet because no really good open source solution for it. When studying JDO specification, there is a query example in it shown below:
"(emps.contains(e1) & e1.dependents > 1) &
(emps.contains(e2) & (e2.salary > 30000 & e1 != e2))"
which means "find deparments wehre there exists an employee with more than 1 dependent and an employee making more than 30,000, and there are 2 different employees satisfying the two conditions"
I am trying to translate this JDO query to Hibernate's criteria query. But I get problem in trnaslating the e1 != e2 expression. Any of you have know how to translate this part?
My current translation is like
sess.createCriteria(Department.class)
.createCriteria("emps")
.add(Restrictions.or(Restrictions.gt("dependents", 1), Restrictions.gt("salary", 3000))
) ....
Rice
|