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     }

 

posted @ 2016-04-27 14:19  下一个雨季~  阅读(336)  评论(0编辑  收藏  举报