I have got exactly the same problem, and was able to resolve it like this:
return criteria.createCriteria(A.class)
.createCriteria("b", "join_between_a_b")
.createCriteria("c", "join_between_b_c")
.createCriteria("d", "join_between_c_d")
.add(Restrictions.eq("some_field_of_D", someValue));
Note: "b"
, "c"
and "d"
in code above refer to attribute names in A
, B
and C
classes, correspondingly (class A
has attribute b
and so on).
For this solution you don't even need to have lazy
and fetch
parameters to be set in your A.hbm.xml
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…