mybatis 调用oracle存储过程 含输入输出

不多说了,很简单,理解了就好了,特意把需要注意的地方标红了.

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;
    }
}



不多说了,看清楚就行了.理解了,怎么样都行






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值