From 31ac883f36edef573f6fa812b88136b32ababa40 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Thu, 3 Jun 2021 11:52:18 +0200 Subject: [PATCH] HHH-14649 Oracle limit handler create wrong sql query when multiple spaces are present in the query (cherry picked from commit 8002b188bbb7f4c799ba1172db833827bb39c259) --- .../hibernate/dialect/pagination/Oracle12LimitHandler.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java index 3067a01a81..c4d7f23f15 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java @@ -52,6 +52,7 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { if ( !hasMaxRows ) { return sql; } + sql = sql.trim(); final LockOptions lockOptions = queryParameters.getLockOptions(); if ( lockOptions != null ) { @@ -83,7 +84,6 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { bindLimitParametersInReverseOrder = false; useMaxForLimit = false; - sql = normalizeStatement( sql ); final int offsetFetchLength; final String offsetFetchString; if ( hasFirstRow ) { @@ -100,7 +100,6 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { private String processSql(String sql, int forUpdateIndex, boolean hasFirstRow) { bindLimitParametersInReverseOrder = true; useMaxForLimit = true; - sql = normalizeStatement( sql ); String forUpdateClause = null; boolean isForUpdate = false; @@ -142,10 +141,6 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { return pagingSelect.toString(); } - private String normalizeStatement(String sql) { - return sql.trim().replaceAll( "\\s+", " " ); - } - private int getForUpdateIndex(String sql) { final int forUpdateLastIndex = sql.toLowerCase( Locale.ROOT ).lastIndexOf( "for update" ); // We need to recognize cases like : select a from t where b = 'for update';