Hibernate Criteria

public List<Personnel> getPersonnelListByOrgCodes(String orgCodes[]){
Criteria criteria = personnelDao.createCriteria();
criteria.createAlias("organization","org");
criteria.add(Restrictions.in("org.code", orgCodes));
ProjectionList projectionList = Projections.projectionList(); 
projectionList.add(Projections.property("id"));
projectionList.add(Projections.property("name"));
criteria.setProjection(projectionList);
criteria.setResultTransformer(Transformers.aliasToBean(Personnel.class));
return criteria.list();
}



你可能感兴趣的:(Hibernate)