Hibernate query criteria for join between 3 tables
问题 I have a sql query: select * from A INNER JOIN B ON A.id = B.id INNER JOIN C ON B.id = C.id INNER JOIN D ON C.id = D.id where D.name = 'XYZ' and D.Sex = 'M' I have been trying to come with hibernate query criteria for the above sql, but having problems. Could anybody help out. 回答1: Criteria c = session.createCriteria(A.class, "a"); .createAlias("a.b", "b") .createAlias("b.c", "c") .createAlias("c.d", "d") .add(Restrictions.eq("d.sex", "M")) .add(Restrictions.eq("d.name", "XYZ")); 回答2: On your