I end up with something like stated below.
Code:
Criteria mainCriteria = session.createCriteria(EntityA.class, "a");
mainCriteria.createCriteria(
"a.bEntities",
"b",
JoinType.LEFT_OUTER_JOIN,
Restrictions.and().add(Restrictions.eq("b.tableId", 1)));
mainCriteria.createCriteria(
"a.cEntities",
"c",
JoinType.LEFT_OUTER_JOIN,
Restrictions.and().add(Restrictions.eq("c.tableId", 2)));
ProjectionList mainCriteriaProjectionList = Projections.projectionList();
mainCriteriaProjectionList.add(Projections.property("a.idA"), "id");
mainCriteriaProjectionList.add(Projections.property("a.colA"), "name");
[b]//*** below colB and colC are not shown in the above image , consider it is there[/b]
mainCriteriaProjectionList.add(Projections.property("b.colB"), "bValue");
mainCriteriaProjectionList.add(Projections.property("c.colC"), "cValue");
mainCriteria.setProjection(memberProjectionList);
memberCriteria.setResultTransformer(new MyResultTransformer());//*** My manual transformer to remove the duplicates.
memberCriteria.list(); [b]// ** Finally the result[/b]
Suggest me the best approach to follow.