欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hibernate setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)

程序员文章站 2022-04-14 22:58:04
...


	/**
	 * 查询专家评审进度
	 * 
	 * @author ZengWenFeng
	 * @date 2017-10-12
	 * @return
	 */
	public List<RepYjZjrwDatabean> queryExpertReviewProgress()
	{
		//SELECT zbmk_id AS xh, COUNT(DISTINCT zj_id) AS cntZj, COUNT(DISTINCT xx_id) AS cntXx, SUM(is_tj) AS sumIsTj FROM t_yj_zjrw GROUP BY zbmk_id ORDER BY xh;
//		GenericQuery query = create("SELECT zbmkId AS xh, COUNT(DISTINCT zjId) AS cntZj, COUNT(DISTINCT xxId) AS cntXx, SUM(isTj) AS sumIsTj FROM RepYjZjrw GROUP BY zbmkId ORDER BY zbmkId");
//		return query.listResult();
		
		String sql = "SELECT zbmk_id AS xh, COUNT(DISTINCT zj_id) AS cntZj, COUNT(DISTINCT xx_id) AS cntXx, SUM(is_tj) AS sumIsTj FROM t_yj_zjrw GROUP BY zbmk_id ORDER BY xh";
		List<Map<String, Object>> list = this.sessionFactory.getCurrentSession().createSQLQuery(sql).setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();
		
		List<RepYjZjrwDatabean> listRepYjZjrwDatabean = new ArrayList<RepYjZjrwDatabean>();
		
		if (list != null && list.size() > 0)
		{
			RepYjZjrwDatabean newRepYjZjrwDatabean = null;
			Map<String, Object> curMap = null;
			for (int i = 0; i < list.size(); i++)
			{
				curMap = list.get(i);
				
				newRepYjZjrwDatabean = new RepYjZjrwDatabean();
				newRepYjZjrwDatabean.setCntXx(curMap.get("CNTXX") != null ? curMap.get("CNTXX").toString() : "");
				newRepYjZjrwDatabean.setCntZj(curMap.get("CNTZJ") != null ? curMap.get("CNTZJ").toString() : "");
				newRepYjZjrwDatabean.setSumIsTj(curMap.get("SUMISTJ") != null ? curMap.get("SUMISTJ").toString() : "");
				newRepYjZjrwDatabean.setXh(curMap.get("XH") != null ? curMap.get("XH").toString() : "");
				
				listRepYjZjrwDatabean.add(newRepYjZjrwDatabean);
			}
		}
		
		return listRepYjZjrwDatabean;
	}


org.hibernate.MappingException: Unknown entity: com.aummis.modules.eva.databean.RepYjZjrwDatabean

http://blog.csdn.net/spencer_tseng/article/details/78185896

hibernate setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)




hibernate setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)




hibernate setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)




hibernate setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)