How to make HIbernate fetch all properties of root entity and only specific properties of associated entity?
问题 I have root entity Hostel and its single association User owner . When I fetch Hostel entity I need to eagerly fetch User owner , but only owner 's 3 properties : userId,firstName,lastName. For now my criteria query is : Criteria criteria = currenSession().createCriteria(Hostel.class); criteria.add(Restrictions.ge("endDate", Calendar.getInstance())); if (StringUtils.notNullAndEmpty(country)) { criteria.add(Restrictions.eq("country", country)); } Long count = (Long) criteria