? ? 最近开发中使用hibernate,发现对于SQL语句和存储过程上面,还是不是很方便,于是自己封装了一个,
下面是存储过程的调用:
String strSql = "{call callcenter_pack.Get_TaskCaseCount(:P_UserID,:P_ErrorInfo,:P_OutData)}"; JdbcQuery query = JdbcUtils.createNativeQuery(super.getConnection(), strSql); query.setParameter("P_UserID", 5); query.setOutParameter("P_ErrorInfo", OracleTypes.VARCHAR); query.setOutParameter("P_OutData", OracleTypes.CURSOR); query.excuteProcedure();
?获取存储过程中的输出参数的结果,包括游标和字符串类型:
String strError = query.getString("P_ErrorInfo"); List<TaskBarCounter> dataList = query.getResultList("P_OutData",TaskBarCounter.class); query.closeCallableStatement();
当然执行修改,新增等也是可以的,这里主要讲查询的使用。
?
?
SQL语句的调用:
public Result findCollect(final QueryMap qMap) { final StringBuilder sb = new StringBuilder(); StringBuilder sbWhere = new StringBuilder(); // select fields sb.append("select c.store_id, s.name,SUM(c.total_recharge) as total_recharge,"); sb.append("SUM(c.total_payment) as total_payment,");