//SQL测试数据自我复制
//将查询结果插入表无需写values();
insert into news(nid,ntid,ntitle,nauthor,ncreatedate,npicpath,nmodifydate,nsummary,ncontent)
select nid_seq.nextval,ntid,ntitle,nauthor,ncreatedate,npicpath,nmodifydate,nsummary,ncontent from news;
commit;
//子查询把全部内容和伪列rownum(as rn)全部查询,再从子查询中通过rn进行数字分页
select * from (select rownum as rn,nid,ntid,ntitle,nauthor,ncreatedate,npicpath,nmodifydate,nsummary,ncontent from news);
//构建一个Pagenation分页工具类,在Biz层和Dao层之间通过它实现分页
package com.sm.util;
import java.util.List;
public class Pagenation<T> {
private int pageNo;
private int pageSize = 10;
private int totalRows;
private int totalPages;
private int prePage;
private int nextPage;
private List<T> items;
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public List<T> getItems() {
return items;
}
public void setItems(List<T> items) {
this.items = items;
}
public int getTotalRows() {
return totalRows;
}
public void setTotalRows(int totalRows) {
this.totalRows = totalRows;
}
public int getTotalPages() {
if(totalRows%pageSize==0){
totalPages=totalRows/pageSize;
}else{
totalPages=totalRows/pageSize+1;
}
return totalPages;
}
/*public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}*/
public int getPrePage() {
return prePage;
}
public void setPrePage(int prePage) {
this.prePage = prePage;
}
public int getNextPage() {
return nextPage;
}
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
}