Skip to content

Commit 4bfb349

Browse files
committed
HHH-1706 - Named parameters ignored when single apostrophe encountered within an SQL comment
(cherry picked from commit 2b56379)
1 parent f6de8f8 commit 4bfb349

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,28 @@ public static void parse(String sqlString, Recognizer recognizer) throws QueryEx
9494
final char c = sqlString.charAt( indx );
9595
final boolean lastCharacter = indx == stringLength-1;
9696

97-
if ( inLineComment ) {
97+
if ( inDelimitedComment ) {
98+
recognizer.other( c );
99+
if ( !lastCharacter && '*' == c && '/' == sqlString.charAt( indx+1 ) ) {
100+
inDelimitedComment = false;
101+
recognizer.other( sqlString.charAt( indx+1 ) );
102+
indx++;
103+
}
104+
}
105+
else if ( !lastCharacter && '/' == c && '*' == sqlString.charAt( indx+1 ) ) {
106+
inDelimitedComment = true;
107+
recognizer.other( c );
108+
recognizer.other( sqlString.charAt( indx+1 ) );
109+
indx++;
110+
}
111+
else if ( inLineComment ) {
112+
recognizer.other( c );
98113
// see if the character ends the line
99114
if ( '\n' == c ) {
100115
inLineComment = false;
101-
recognizer.other( c );
102116
}
103117
else if ( '\r' == c ) {
104118
inLineComment = false;
105-
recognizer.other( c );
106119
if ( !lastCharacter && '\n' == sqlString.charAt( indx+1 ) ) {
107120
recognizer.other( sqlString.charAt( indx+1 ) );
108121
indx++;
@@ -117,20 +130,6 @@ else if ( '-' == c ) {
117130
indx++;
118131
}
119132
}
120-
else if ( inDelimitedComment ) {
121-
recognizer.other( c );
122-
if ( !lastCharacter && '*' == c && '/' == sqlString.charAt( indx+1 ) ) {
123-
inDelimitedComment = true;
124-
recognizer.other( sqlString.charAt( indx+1 ) );
125-
indx++;
126-
}
127-
}
128-
else if ( !lastCharacter && '/' == c && '*' == sqlString.charAt( indx+1 ) ) {
129-
inDelimitedComment = true;
130-
recognizer.other( c );
131-
recognizer.other( sqlString.charAt( indx+1 ) );
132-
indx++;
133-
}
134133
else if ( inDoubleQuotes ) {
135134
if ( '\"' == c ) {
136135
inDoubleQuotes = false;

0 commit comments

Comments
 (0)