private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } /** * 通过SQL执行无返回结果的存储过程(仅限于存储过程) * * @param queryString * @param params */ public void executeVoidProcedureSql(final String queryString, final Object[] params) throws Exception { Session session = sessionFactory.getCurrentSession(); session.doWork(new Work() { public void execute(Connection conn) throws SQLException { ResultSet rs = null; CallableStatement call = conn.prepareCall("{" + queryString + "}"); if (null != params) { for (int i = 0; i < params.length; i++) { call.setObject(i + 1, params[i]); } } rs = call.executeQuery(); call.close(); rs.close(); } }); } /** * 通过存储过程查询(单结果集) * * @param sql * 查询sql * @param params * 参数 * @param columnNum * 返回的列数 * @return */ public List