package com.atChina.dao;

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

import org.apache.ibatis.annotations.Param;

import com.atChina.bean.Employee;

public interface EmployeeMapper {

	public List<Employee> getEmployeeById(Integer depno);

}

 sql映射文件,查询配置

<!-- 
	  resultType:如果查询方法返回的是一个集合,要写集合中元素的类型
	 -->
	<select
		id="getEmployeeById"  
		resultType="com.atChina.bean.Employee" >
		select * from DEPTTEST where deptno >= #{deptno}
	</select>

测试方法:

@Test
	public void test2() throws IOException {
		String resource = "mybatis-config.xml";
		InputStream inputStream = Resources.getResourceAsStream(resource);
		
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		
		SqlSession openSession = sqlSessionFactory.openSession();
		try{
			// 命名空间.id,这样别的配置文件里有同名的id,程序也不报错
			EmployeeMapper em = openSession.getMapper(EmployeeMapper.class);
			System.out.println(em.getClass()); // 动态代理类

			List<Employee> ee = em.getEmployeeById(10);
			System.out.println(ee.size());
		}finally{
			// 关闭
			openSession.close();
		}
	}