fix error reported for empty HQL string

This commit is contained in:
Gavin 2023-06-10 23:13:19 +02:00 committed by Gavin King
parent e0d08a5f26
commit bc81eb6d19
1 changed files with 8 additions and 3 deletions

View File

@ -159,9 +159,14 @@ public class StandardHqlTranslator implements HqlTranslator {
}
if ( e instanceof NoViableAltException ) {
errorText += message.substring( 0, message.indexOf("'") );
String lineText = hql.lines().collect( toList() ).get( line -1 );
String text = lineText.substring( 0, charPositionInLine) + "*" + lineText.substring(charPositionInLine);
errorText += "'" + text + "'";
if ( hql.isEmpty() ) {
errorText += "'*' (empty query string)";
}
else {
String lineText = hql.lines().collect( toList() ).get( line -1 );
String text = lineText.substring( 0, charPositionInLine) + "*" + lineText.substring(charPositionInLine);
errorText += "'" + text + "'";
}
}
else if ( e instanceof InputMismatchException ) {
errorText += message.substring( 0, message.length()-1 )