下面就用一个例子来测试Mybatis调用存储过程,并进行分页的例子:OA现金盘平台开发(企 娥:217 1793 408)
使用的是oracle数据库
1 存储过程代码如下:
create or replace procedure test_page(
page_start in int,page_end in int,page_count out int,
page_emps out sys_refcursor)
as
begin
select count() into page_count from employees;
open page_emps for
select from
(select rownum rn,e.* from employees e
where rownum <= page_end)
where rn >= page_start;
end test_page;
2 Page.java
package com.lxj.bean;
import java.util.List;
public class Page {
// 起始
private Integer start;
// 结束
private Integer end;
// 总数
private Integer count;
// 数据库中查询出来的员工
private List<Employee> emps;
public Integer getStart() {
return start;
}
public void setStart(Integer start) {
this.start = start;
}
public Integer getEnd() {
return end;
}
public void setEnd(Integer end) {
this.end = end;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public List<Employee> getEmps() {
return emps;
}
public void setEmps(List<Employee> emps) {
this.emps = emps;
}
@Override
public String toString() {
return "Page [start=" + start + ", end=" + end + ", count=" + count + ", emps=" + emps + "]";
}
原文地址:http://blog.51cto.com/13880687/2147964
时间: 2024-10-13 01:05:40