diff --git a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java index f63f2c483c..e392cdea07 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java @@ -94,15 +94,28 @@ public static void parse(String sqlString, Recognizer recognizer) throws QueryEx final char c = sqlString.charAt( indx ); final boolean lastCharacter = indx == stringLength-1; - if ( inLineComment ) { + if ( inDelimitedComment ) { + recognizer.other( c ); + if ( !lastCharacter && '*' == c && '/' == sqlString.charAt( indx+1 ) ) { + inDelimitedComment = false; + recognizer.other( sqlString.charAt( indx+1 ) ); + indx++; + } + } + else if ( !lastCharacter && '/' == c && '*' == sqlString.charAt( indx+1 ) ) { + inDelimitedComment = true; + recognizer.other( c ); + recognizer.other( sqlString.charAt( indx+1 ) ); + indx++; + } + else if ( inLineComment ) { + recognizer.other( c ); // see if the character ends the line if ( '\n' == c ) { inLineComment = false; - recognizer.other( c ); } else if ( '\r' == c ) { inLineComment = false; - recognizer.other( c ); if ( !lastCharacter && '\n' == sqlString.charAt( indx+1 ) ) { recognizer.other( sqlString.charAt( indx+1 ) ); indx++; @@ -117,20 +130,6 @@ else if ( '-' == c ) { indx++; } } - else if ( inDelimitedComment ) { - recognizer.other( c ); - if ( !lastCharacter && '*' == c && '/' == sqlString.charAt( indx+1 ) ) { - inDelimitedComment = true; - recognizer.other( sqlString.charAt( indx+1 ) ); - indx++; - } - } - else if ( !lastCharacter && '/' == c && '*' == sqlString.charAt( indx+1 ) ) { - inDelimitedComment = true; - recognizer.other( c ); - recognizer.other( sqlString.charAt( indx+1 ) ); - indx++; - } else if ( inDoubleQuotes ) { if ( '\"' == c ) { inDoubleQuotes = false;