import java.io.Serializable;
public class City implements Serializable{
private Integer cid;
private String cname;
public City() {
super();
}
public Integer getCid() {
return cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
}
package com.my.mapper;
import java.util.Map;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;
import com.my.entity.City;
public interface ICityMapper {
@Results(id = “rs”, value = {
@Result(property = “cid”, column = “CID”, id = true),
@Result(property = “cname”, column = “CNAME”)
})
@Select({“call pro_city(#{page,mode=IN,jdbcType=INTEGER},#{size,mode=IN,jdbcType=INTEGER},#{cur,mode=OUT,jdbcType=CURSOR,resultMap=rs},#{allcount,mode=OUT,jdbcType=INTEGER},#{allpage,mode=OUT,jdbcType=INTEGER})”})
@ResultType(com.my.entity.City.class)
@Options(statementType=StatementType.CALLABLE)
public void OpPage(Map map);
@Select(“select *from city c where c.cid=#{cid}”)
public City getCity(int cid);
}
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.type.JdbcType;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.my.entity.City;
import com.my.entity.User;
import com.my.service.ICityService;
import com.my.service.IUserService;
public class Test {
public static void main(String[] args) throws SQLException {
// TODO Auto-generated method stub
BeanFactory bf=new ClassPathXmlApplicationContext(“applicationContext.xml”);
ICityService us=(ICityService)bf.getBean(“cityService”);
Map map=new HashMap();
map.put(“page”, 1);
map.put(“size”, 5);
us.OpPage(map);
Listlist=(List)map.get(“cur”);
System.out.println(map.get(“cur”));
for (City city : list) {
System.out.println(city.getCname());
}
}
}