diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/query/internal/SelectStatementBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/query/internal/SelectStatementBuilder.java index cae82d79ea..3d2b1d8ac3 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/query/internal/SelectStatementBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/query/internal/SelectStatementBuilder.java @@ -184,7 +184,7 @@ public class SelectStatementBuilder { * @return the SQL SELECT statement. */ public String toStatementString() { - final StringBuilder buf = new StringBuilder( guesstimatedBufferSize ); + StringBuilder buf = new StringBuilder( guesstimatedBufferSize ); if ( StringHelper.isNotEmpty( comment ) ) { buf.append( "/* " ).append( comment ).append( " */ " ); @@ -219,7 +219,7 @@ public class SelectStatementBuilder { } if ( lockOptions.getLockMode() != LockMode.NONE ) { - buf.append( dialect.getForUpdateString( lockOptions ) ); + buf = new StringBuilder(dialect.applyLocksToSql( buf.toString(), lockOptions, null ) ); } return dialect.transformSelectString( buf.toString() ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/SimpleSelect.java b/hibernate-core/src/main/java/org/hibernate/sql/SimpleSelect.java index bebdf955ef..51fbc86482 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/SimpleSelect.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/SimpleSelect.java @@ -179,7 +179,7 @@ public class SimpleSelect { } if ( lockOptions != null ) { - buf.append( dialect.getForUpdateString( lockOptions ) ); + buf = new StringBuilder(dialect.applyLocksToSql( buf.toString(), lockOptions, null ) ); } return dialect.transformSelectString( buf.toString() );