修复DB工具分页查询的时候oracle数据库会把ROWNUM_也带出来问题

This commit is contained in:
Looly 2022-09-24 11:59:15 +08:00
parent 186289c979
commit eb370bf32e
3 changed files with 11 additions and 3 deletions

View File

@ -20,6 +20,7 @@
* 【core 】 修复ReflectUtil 反射方法中桥接判断问题issue#2625@Github
* 【poi 】 修复ExcelWriter导出List<Map>引起的个数混乱问题issue#2627@Github
* 【poi 】 修复ExcelReader读取时间变成12小时形式问题issue#I5Q1TW@Gitee
* 【db 】 修复DB工具分页查询的时候oracle数据库会把ROWNUM_也带出来问题issue#2618@Github
-------------------------------------------------------------------------------------------------------------

View File

@ -35,8 +35,8 @@ public class OracleDialect extends AnsiSqlDialect {
return find
.insertPreFragment("SELECT * FROM ( SELECT row_.*, rownum rownum_ from ( ")
.append(" ) row_ where rownum <= ").append(startEnd[1])//
.append(") table_alias")//
.append(" where table_alias.rownum_ > ").append(startEnd[0]);//
.append(") table_alias_")//
.append(" where table_alias_.rownum_ > ").append(startEnd[0]);//
}
@Override

View File

@ -149,9 +149,16 @@ public class HandleHelper {
*/
public static <T extends Entity> T handleRow(T row, int columnCount, ResultSetMetaData meta, ResultSet rs, boolean withMetaInfo) throws SQLException {
int type;
String columnLabel;
for (int i = 1; i <= columnCount; i++) {
type = meta.getColumnType(i);
row.put(meta.getColumnLabel(i), getColumnValue(rs, i, type, null));
columnLabel = meta.getColumnLabel(i);
if("rownum_".equalsIgnoreCase(columnLabel)){
// issue#2618@Github
// 分页时会查出rownum字段此处忽略掉读取
continue;
}
row.put(columnLabel, getColumnValue(rs, i, type, null));
}
if (withMetaInfo) {
try {