hibernate指定查询字段
1 @Override 2 public List<ArtVenue> listByAll(String... fields) { 3 DetachedCriteria dc = DetachedCriteria.forClass(ArtVenue.class); 4 if(fields != null && fields.length > 0){ 5 ProjectionList list = Projections.projectionList(); 6 list.add(Projections.property(idField.getName()).as(idField.getName())); 7 for (String field : fields) { 8 list.add(Projections.property(field).as(field)); 9 } 10 dc.setProjection(list).setResultTransformer(Transformers.aliasToBean(ArtVenue.class)); 11 } 12 return find(dc); 13 }