diff --git a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java index 33466c6a7c..b5746d6a64 100755 --- a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import org.hibernate.QueryException; import org.hibernate.engine.query.spi.ParameterParser; @@ -24,6 +25,7 @@ import org.hibernate.persister.entity.SQLLoadable; * @author Paul Benedict */ public class SQLQueryParser { + private static final Pattern PREPARED_STATEMENT_PATTERN = Pattern.compile( "^\\{.*?\\}$" ); private static final String HIBERNATE_PLACEHOLDER_PREFIX = "h-"; private static final String DOMAIN_PLACEHOLDER = "h-domain"; private static final String CATALOG_PLACEHOLDER = "h-catalog"; @@ -74,6 +76,10 @@ public class SQLQueryParser { // don't get'em'all we throw an exception! Way better than trial and error ;) protected String substituteBrackets(String sqlQuery) throws QueryException { + if ( PREPARED_STATEMENT_PATTERN.matcher( sqlQuery ).matches() ) { + return sqlQuery; + } + StringBuilder result = new StringBuilder( sqlQuery.length() + 20 ); int left, right;