SSH2三大框架SQL查询

       /**
	 * 查询省份名称
	 * @author YHD
	 * @return
	 * @see
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Province> findProvince() 
	{
		List<Province> proList = new ArrayList<Province>();
		StringBuffer sb = new StringBuffer();
		sb.append("SELECT ");
		sb.append("t.province_code,");
		sb.append("t.province_name,");
		sb.append("FROM ");
		sb.append("t_province_tab t ");
		sb.append("order by t.province_code ");
		SQLQuery query = getSession().createSQLQuery(sb.toString());
		List<Object[]> list = query.list();
		if(null != list && list.size() > 0)
		{
			Province pro = null;
			for(Object[] obj:list)
			{
				pro = new Province();
				pro.setProvinceCode(null==obj[0]? "":obj[0].toString());
				pro.setProvinceCode(null==obj[1]? "":obj[1].toString());
				proList.add(pro);
			}
		}
		return proList;
	}



SSH2三大框架SQL查询

上一篇:[转] (CQRS)命令和查询责任分离架构模式(二) 之 Command的实现


下一篇:MongoDB自学笔记11---4.3 删除文档