hibernate调用存储过程(DAO实现层)/** * 根据用户id获得用户联系方式 prUser_getUserPhone */ public User getUserPhoneNo(final int userId) { Util .log("@@@@@@@@@@@UserDAOImp -> getUserPhoneNo in :userId:" + userId); User user = (User) this.getHibernateTemplate().execute( new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Connection connection = session.connection(); // 1.查询用户自己的联系方式 CallableStatement callableStatement1 = connection .prepareCall("prUser_getUserPhone(?,?,?,?)"); // 传参 callableStatement1.setInt(1, userId);// 123123 callableStatement1.registerOutParameter(2, Types.VARCHAR); callableStatement1.registerOutParameter(3, Types.INTEGER); callableStatement1.registerOutParameter(4, Types.VARCHAR); // 执行查询 boolean i = callableStatement1.execute(); System.out.print("返回的结果:" + i); // 用户联系信息 Util.log("用户的电话::" + callableStatement1.getObject(2)); Util.log("查询结果id:" + callableStatement1.getObject(3)); Util.log("查询结果信息:" + callableStatement1.getObject(4)); User user = new User(); user.setUserId(userId); user.setPhone((String) callableStatement1.getObject(2)); user.setResCode((Integer) callableStatement1 .getObject(3)); user.setResInfo((String) callableStatement1 .getObject(4)); callableStatement1.close(); connection.close(); return user; } }); Util.log("@@@@@@@@@@@UserDAOImp -> getUserPhoneNo out!"); return user; }