mybaties和orcale数据库连接返回游标结果注解方式配置

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

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@沫沫@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值