其他分享
首页 > 其他分享> > hibernate结果集多种映射方案

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;

标签:方案,createSQLQuery,hibernate,映射,list,List,getSession,SQLQuery,sqlMo
来源: https://www.cnblogs.com/sung1024/p/12049909.html