oracle存储过程
CREATE OR REPLACE Procedure getTeacher(cur_arg out Sys_Refcursor) As begin open cur_arg for select * from t_user; End;
mybatis配置文件
<select id="<span style="color:#ff0000;">getAllAccountProc</span>" statementType="CALLABLE" parameterType="java.util.Map" > {call GETTEACHER(#{<span style="color:#ff0000;">result</span>,jdbcType=CURSOR,mode=OUT,javaType=ResultSet, resultMap=<span style="color:#ff0000;"><strong><strong>accountResultMap</strong></strong></span>})} </select>
result:返回的接收,result,map 的key
<span xmlns="http://www.w3.org/1999/xhtml" style=""><strong xmlns="http://www.w3.org/1999/xhtml"><strong><strong>userResultMap</strong></strong></strong></span> 对应返回类型的id
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.gwtjs.mapper.AccountMapper"> <resultMap type="com.gwtjs.entity.Account" id="<span style="color:#ff0000;"><strong>userResultMap</strong></span>"> <id property="accountId" column="ID" /> <result property="username" column="USERNAME" /> <result property="password" column="PASSWORD" /> <result property="createTime" column="CREATETIME" /> </resultMap> </mapper>
java mapper接口
public interface AccountMapper<T extends Account> extends BaseSqlMapper<T> { public Map<String, Object> <span style="color:#ff0000;">getAllAccountProc</span>(Map<String, Object> map) throws DataAccessException; }
dao
package com.gwtjs.dao.impl; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Repository; import com.gwtjs.dao.AccountDao; import com.gwtjs.dao.BaseMapperDao; import com.gwtjs.entity.Account; import com.gwtjs.mapper.AccountMapper; /** */ @SuppressWarnings("unchecked") @Repository("accountDao") public class AccountDaoImpl<T extends Account> implements AccountDao<T> { @Inject private BaseMapperDao<Account> dao; public List<Account> getAllAccountProc() throws DataAccessException { dao.setMapperClass(AccountMapper.class); Map<String, Object> map = new HashMap<String, Object>(); ((AccountMapper)dao.getMapper()).getAllAccountProc(map); List<Account> list = (List<Account>)map.get("result"); System.out.println("result: ======================\n"+list); /**/ return list; } }
不多说了,看清楚就行了.理解了,怎么样都行