From c84cc32297250067c77be4be4fb50807209c1ef7 Mon Sep 17 00:00:00 2001 From: drepshas Date: Fri, 4 Sep 2015 13:15:46 -0700 Subject: [PATCH] HHH-10087 allow locks to be prepended to SQL This allows locking code to work for the Teradata database (cherry picked from commit ac616ccbfa5e1ea659b2c2df49c4adf26b05e51e) --- .../plan/exec/query/internal/SelectStatementBuilder.java | 4 ++-- .../src/main/java/org/hibernate/sql/SimpleSelect.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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() );