再测一个mybatis调用oracle过程

<?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">
<!-- namespace和定义的Mapper接口对应,并实现其中的方法 -->
<mapper namespace="com.gwtjs.mapper.AccountMapper">

	<!-- CREATE OR REPLACE Procedure getTeacher(cur_arg out Sys_Refcursor) As 
		begin open cur_arg for select * from t_user; End; / -->

	<select id="getPagerProc" statementType="CALLABLE"
		parameterType="java.util.Map">
		{call pager_proc(
		#{tableName,mode=IN,jdbcType=VARCHAR},
		#{empNo,mode=IN,jdbcType=VARCHAR},
		#{myPageSize,mode=IN,jdbcType=INTEGER},
		#{pageNow,mode=IN,jdbcType=INTEGER},
		#{myRows,mode=OUT,jdbcType=INTEGER},
		#{myPageCount,mode=OUT,jdbcType=INTEGER},
		#{result,jdbcType=CURSOR,mode=OUT,javaType=ResultSet, resultMap=userResultMap2})}
	</select>

</mapper>

<?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="userResultMap2">
		<result property="username" column="USER_NAME" />
		<result property="password" column="USER_PASSWORD" />
	</resultMap>
</mapper>


import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;
import org.springframework.dao.DataAccessException;

import com.gwtjs.entity.Account;

/**
 * <b>function:</b>继承SqlMapper,MyBatis数据操作接口;此接口无需实现类
 * @version 1.0
 */
public interface AccountMapper<T extends Account> extends BaseSqlMapper<T> {
	
	public Map<String, Object> getPagerProc(Map<String, Object> result) ;
}


package com.gwtjs.dao;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.gwtjs.entity.Account;

/**
 */
public interface AccountDao<T> {
	
	public Map<String, Object> getPagerProc(Map<String, Object> result) ;
}


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 Map<String, Object> getPagerProc(Map<String, Object> result) {
		dao.setMapperClass(AccountMapper.class);
		((AccountMapper) dao.getMapper()).getPagerProc(result);
		return result;
	}
}


package com.gwtjs.dao;

import static org.junit.Assert.assertNotNull;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.gwtjs.entity.Account;

public class AccountDaoTest extends SpringTestBase {
	
	@Autowired
	private AccountDao<Account> accountDao;
	
	@Test
	public void testBaseConfig() {
		// TODO Auto-generated method stub
		assertNotNull(accountDao);
	}

	@Test
    public void testGetPagerProc() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("tableName", "SYS_USERS");//表名
        map.put("empNo", "USER_ID");//排序名
        map.put("myPageSize", 12); //页大小
        map.put("pageNow", 1);//第几页
        Map<String, Object> result = accountDao.getPagerProc(map);
        System.out.println("Hello procedure "+result);
    }

}

过程--->




你可能感兴趣的:(再测一个mybatis调用oracle过程)