如何为给定的sql查询编写hibernate条件查询?
SELECT * FROM Customers
WHERE Country='Germany'
AND (City='Berlin' OR City='Munchen');
答案 0 :(得分:1)
Criteria criteria = session.createCriteria(Customers.class);
criteria.add(Restrictions.eq("Country", "Germany"));
criteria.add(Restrictions.or(
Restrictions.eq("City", "Berlin"),
Restrictions.eq("City", "Munchen")));