Hi all, I have 3 tables that I need to join: TableA, TableB and TableC. TableA is totally standalone, but TableB and TableC are related via one-to-many mapping (yay!) Here's my working join using Criteria API. DetachedCriteria tableBnCJoin= DetachedCriteria.forClass(TableB.class); tableBnCJoin.setProjection(Projections.property("tableBEmployeeId"));
Criteria tableACriteria = getSession().createCriteria(TableA.class); criteria.add(org.hibernate.criterion.Property.forName("tableAEmployeeId").in(tableBnCJoin)); criteria.setProjection(Projections.projectionList() .add(Projections.distinct(Projections.property("tableAEmployeeId"))) .add(Projections.property("tableAEmployeeName")));
That all works well, but now I need to return TableCEmployeeAddress from TableC. How do I add the column TableCEmployeeAddress returned? Do I add the projection to tabBnCJoin criteria or tableACriteria?
Thank you so much in advance
|