If you're using HQL for your queries, you can specify your eager fetching using the "fetch" keyword, like so:
from Cat as cat
inner join fetch cat.mate
left join fetch cat.kittens child
left join fetch child.kittens
If you're using the Criteria Query API, you can specify the fetch mode using setFetchMode
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.setFetchMode("mate", FetchMode.EAGER)
.setFetchMode("kittens", FetchMode.EAGER)
.list();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…