HHH-14649 Oracle limit handler create wrong sql query when multiple spaces are present in the query

(cherry picked from commit 8002b188bb)
This commit is contained in:
Andrea Boriero 2021-06-03 11:52:18 +02:00 committed by gbadner
parent 8f21f9d701
commit 31ac883f36
1 changed files with 1 additions and 6 deletions

View File

@ -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';