hibernate结果集多种映射方案

String sql = "select marker_no AS markerNo,name from lv_marker";
String sqlMo = "select * from lv_marker";


//------------------------------------------------------------------------------
SQLQuery query = this.getSession().createSQLQuery(sql);
query.setResultTransformer(Transformers.aliasToBean(MarkerBfVO.class));
List<MarkerBfVO> resultsVO = query.list();

//------------------------------------------------------------------------------
SQLQuery queryMo = this.getSession().createSQLQuery(sqlMo).addEntity(Marker.class);
List<Marker> resultsMo = queryMo.list();

//------------------------------------------------------------------------------
SQLQuery queryMap = this.getSession().createSQLQuery(sqlMo);
queryMap.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
List<Map<String,Object>> resultsMap = queryMap.list();

//------------------------------------------------------------------------------
SQLQuery queryObjs = this.getSession().createSQLQuery(sqlMo);
List<Object[]> resultsObjs = queryObjs.list();
return resultsVO;

上一篇:request.getSession().getServletContext().getRealPath("/");


下一篇:javaEE四大作用域(共享域)