i have a simple Criteria which is used by get the school of a student which i have the ID i need only the school not the student i have a simple coding like
public School loadSchool(Integer studentID) { final Session session = getHibernateTemplate().getSessionFactory().openSession(); final Criteria like = session.createCriteria(Student.class) .add(idEq(studentID)) .setFetchMode("School",FetchMode.JOIN); final School retValue = ((Student)like.uniqueResult()).getSchool(); session.close(); return retValue; } as you can see i retrieve the Student and the School as well i need only the School my question are
1). there is a way other than setProjections() that i could extract[retrieve from the DB] only the School fields not the Student fields because are to many fields and is a kind annoying listing all the fields in setProjection and affects performance something like
setProjectionOnlyPropertiesForClass(School.class).
2). there is any workaround.
thanks a lot.