//hibernate查询部分字段转换成实体bean

    /*** 查询线路信息*/@Overridepublic List<Line> getSimpleLineListByTj(Map<String,Object>paramMap){

Criteria cr
=this.getSession().createCriteria(Line.class,"Line");//cr.setFetchMode("chuTuanInfo", FetchMode.JOIN);//Criteria teamche=cr.createAlias("chuTuanInfo","chuTuanInfo", JoinType.LEFT_OUTER_JOIN);//Criteria teamPlanCR=cr.createAlias("teamplan","teamplan", JoinType.LEFT_OUTER_JOIN); ProjectionList pList=Projections.projectionList();//pList.add(Projections.property("id"));//pList.add(Projections.property("linename")); pList.add(Projections.alias(Projections.property("id"), "id"));//使用别名才能aliasToBean到Line pList.add(Projections.alias(Projections.property("linename"), "linename"));//pList.add(Projections.property("teamplan.renshu")); cr.setProjection(pList);//FaTuanState.getMap();//List<String> propertyNameList = new ArrayList();//propertyNameList.add("id");//propertyNameList.add("linename");//List list = getListWithPartProperty(cr, propertyNameList);//Map<String,Object> paramMap = new HashMap<String,Object>();//paramMap.put(key, value); cr.add(Restrictions.ne("state", FaTuanState.TINGFA));//《》停发和暂停的 cr.add(Restrictions.ne("state", FaTuanState.ZANTING));if(paramMap.get("areaid")!=null && !StringUtils.isBlank(paramMap.get("areaid").toString())){
cr.add(Restrictions.eq(
"jingqu.id", Integer.parseInt(paramMap.get("areaid").toString())));
}


cr.addOrder(Order.asc(
"linename"));
cr.setResultTransformer(Transformers.aliasToBean(Line.
class));returncr.list();
}

 

标签: none


阿里云优惠主机

添加新评论

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系238611804@139.com。我们会在24小时内进行删除。