Hibernate 调用存储过程(二)

前面有一篇文章介绍过一次hibernate调用存储过程

上次的存储过程。是直接两个参数返回结果集。

这次有所不同。参数里面带有out输出参数。来返回的结果集。

找了很久发现hibernate是不直接支持out参数的。。

在这里只能有JDBC了。

 

public List<SearchReportDto1061> shishiCount(String dwbh, String date){
	 List<SearchReportDto1061> list = new ArrayList<SearchReportDto1061>();
	 Connection con = getSession().connection();//通过hibernate得到的连接   
     String sql="{Call statistics_report.report_31_calc(?,?,?)}";
     ResultSet  rs = null;
     try {
    	CallableStatement cs = con.prepareCall(sql);
		cs.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);//out参数
		cs.setString(2, dwbh);
	    cs.setString(3, date);
	    rs=cs.executeQuery();
	   rs=(ResultSet)cs.getObject(1);
	    while(rs.next())
	    {
	    	SearchReportDto1061 entity=new SearchReportDto1061();
	    	entity.setVaccineCode(rs.getString(1));
	    	entity.setInjectionno(rs.getString(2));
	    	entity.setLocalShouldNumber(rs.getInt(3));
	    	entity.setLocalInoculatedNumber(rs.getInt(4));
	    	entity.setOutlandshouldnumber(rs.getInt(5));
	    	entity.setOutlandinoculatednumber(rs.getInt(6));
	    	list.add(entity);
	    }
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return list;
 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值