ibatis3.x学习之oracle存储过程调用之回到结果集配置

ibatis3.x学习之oracle存储过程调用之返回结果集配置
package org.yhb.ibatis.model;

import java.io.Serializable;
import java.util.Date;

public class User implements Serializable{
	private static final long serialVersionUID = -6919964218508186044L;
	private int id;
	private String name;
	private Date birthday;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
}

 

<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD iBatis Mapper 3.0 //EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="org.yhb.ibatis.dao.UserDAO">
	<!-- 表结构
		create table IBATIS_USER
		(
		  ID       NUMBER not null,
		  NAME     VARCHAR2(20) not null,
		  BRITHDAY DATE not null
		)
	-->
	
	<!-- 存储过程
		create or replace procedure getAllUser(userList out sys_refcursor)
		as
		begin
		   open userList for select * from ibatis_user;
		end;
	 -->
	 
	<!-- resultMap -->
	<resultMap type="User" id="userMap">
		<id column="id" property="id" />
		<result column="name" property="name" />
		<result column="birthday" property="birthday" />
	</resultMap>

	<!-- 调用存储过程 -->
	<select id="getAllUser" statementType="CALLABLE">
		{call
		  getAllUser(#{userList,<!-- 参数 -->
		  			   mode=OUT,<!-- 参数类型 -->
		  			   javaType=java.sql.ResultSet,<!-- 参数java类型 -->
		  			   jdbcType=CURSOR,<!-- 参数jdbc类型 -->
		  			   resultMap=userMap<!-- ResultSet需要resultMap参数 -->
		  			   })}
	</select>
</mapper>

 

	@Test
	public void testProcedure() throws Exception {
		Reader reader = null;
		reader = Resources.getResourceAsReader("configuration.xml");
		SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(reader);
		reader.close();
		
		SqlSession session = ssf.openSession();
		Map map = new HashMap();
		session.selectOne("org.yhb.ibatis.dao.UserDAO.getAllUser", map);
		System.out.println(map);
		//返回的集合被放入了map中
		List<User> userList = (List<User>) map.get("userList");
		System.out.println(userList);
		session.close();
	}

 

1 楼 chen00zhou 2011-01-19  
如果存储过程是多个out的参数值呢?
如何处理?

我的异常网推荐解决方案:oracle存储过程,http://www..net/oracle-develop/177537.html