mysql转oracle时sql分页

	public List<FunctionSupplement> getFunctionListSupplement(Page page,String searchAll) {
		String str = "SELECT * FROM libraryfunctionsupplement ";
		StringBuffer sql=new StringBuffer(str);
		sql.append(" or wire_material_code like '%"+searchAll+"%'");
		if (StringUtils.isNotEmpty(searchAll)) {
			sql.append(" or wire_csa = "+searchAll+"")
			.append(" or copper_material_cost = "+searchAll+"")
			.append(" or copper_weight = "+searchAll+"")
			.append(" or copper_base_price = "+searchAll+"")
			.append(" or aluminum_weight = "+searchAll+"")
			.append(" or aluminum_base_price = "+searchAll+"");
		}
		sql.append(" order by gmt_created desc");
			//.append(" limit "+firstIndex+","+page.getPageSize());
		String oraclePageSql = getOraclePageSql(sql.toString(),page);
		List<FunctionSupplement> functionList = createSQLQuery(oraclePageSql.replaceFirst("or","where")).addEntity(FunctionSupplement.class).list();
		return functionList;
	}

	private String getOraclePageSql(String sql, Page page) {
		int firstIndex = page.getFirst();
		int lastIndex = page.getPageNo()*page.getPageSize();
		String oraclePageSql = " SELECT * FROM ( SELECT A.*, ROWNUM RN FROM ("+sql+") A WHERE ROWNUM <= "+lastIndex+" ) WHERE RN >= "+firstIndex;
		return oraclePageSql;
	}

阅读更多
文章标签: oracle mysql
上一篇addScalar
下一篇merge
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭