修复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

@@ -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 {