Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3
I want use the DetachedCriteria to query sth , I want to change the relation between the master records and detail records to
left outer join, but when I execute the following code, I find it cannot work ,the relation is still
inner join ! , thanks for help !
Below is the code :
//declare a detachedCriteria, root class is A01 and it has a36s ,a02s,a08s ... collection properties.
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(A01.class,
"a01").setResultTransformer(DetachedCriteria.
DISTINCT_ROOT_ENTITY);
//create the alias , and want to make the detachedCriteria left outer join the a36s.
detachedCriteria.setFetchMode("a36s", org.hibernate.FetchMode.JOIN);
detachedCriteria.createAlias("a36s","a36");
detachedCriteria.add(Restrictions.eq("a36.gb4761.code","11"));
//create the alias , and want to make the detachedCriteria left outer join the a36s.
detachedCriteria.setFetchMode("a03s", org.hibernate.FetchMode.JOIN);
detachedCriteria.createAlias("a03s","a03");
detachedCriteria.add(Restrictions.eq("a03.code","12"));