@Test public void testJoinFetch() { String hqlString = "select distinct project from Tproject project left join fetch project.departmentSet department" + " where department.name like '%一分%' "; List<Tproject> list = projectDao.find(hqlString); for (Tproject project : list) { Long id = (Long) project.getId(); projectDao.getCurrentSession().evict(project); Tproject p = projectDao.get(Tproject.class, id); /*System.out.println(project.getDepartmentSet().size());*/ int size = p.getDepartmentSet().size(); // size=project.getDepartmentSet().size(); if (size > 1) System.out.println(size); } }
@Test public void testGet() { Tproject project = projectDao.get(Tproject.class, 8L); System.out.println(project.getDepartmentSet().size()); }