HHH-12175: ParameterParser doesn't handle JPA positional parameters correctly
This commit is contained in:
parent
90cabb43ad
commit
8eaf649aa3
|
@ -181,7 +181,7 @@ public class ParameterParser {
|
|||
}
|
||||
else if ( c == '?' ) {
|
||||
// could be either an ordinal or JPA-positional parameter
|
||||
if ( indx < stringLength - 2 && Character.isDigit( sqlString.charAt( indx + 1 ) ) ) {
|
||||
if ( indx < stringLength - 1 && Character.isDigit( sqlString.charAt( indx + 1 ) ) ) {
|
||||
// a peek ahead showed this as an JPA-positional parameter
|
||||
final int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
|
||||
final int chopLocation = right < 0 ? sqlString.length() : right;
|
||||
|
|
|
@ -124,5 +124,15 @@ public class ParameterParserTest {
|
|||
assertTrue(recognizer.getNamedParameterDescriptionMap().containsKey("pxyz"));
|
||||
assertEquals( 2, recognizer.getNamedParameterDescriptionMap().size() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseJPAPositionalParameter() {
|
||||
ParamLocationRecognizer recognizer = new ParamLocationRecognizer( 0 );
|
||||
ParameterParser.parse("from Stock s where s.stockCode = ?1 and s.xyz = ?1", recognizer);
|
||||
assertEquals( 1, recognizer.getOrdinalParameterDescriptionMap().size() );
|
||||
|
||||
ParameterParser.parse("from Stock s where s.stockCode = ?1 and s.xyz = ?2", recognizer);
|
||||
assertEquals( 2, recognizer.getOrdinalParameterDescriptionMap().size() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue