diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java index 0591230ff4..3ec4fbadc8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java @@ -1515,16 +1515,15 @@ public class NativeQueryImpl final StringBuilder buffer = new StringBuilder( "ParameterInterpretationImpl (" ) .append( sqlString ) .append( ") : {" ); - - for ( int i = 0, size = parameterList.size(); i < size; i++ ) { - buffer.append( System.lineSeparator() ).append( " " ); - - if ( i != size - 1 ) { - buffer.append( "," ); + final String lineSeparator = System.lineSeparator(); + if ( CollectionHelper.isNotEmpty( parameterList ) ) { + for ( int i = 0, size = parameterList.size(); i < size; i++ ) { + buffer.append( lineSeparator ).append( " ," ); } + buffer.setLength( buffer.length() - 1 ); } - return buffer.append( System.lineSeparator() ).append( "}" ).toString(); + return buffer.append( lineSeparator ).append( "}" ).toString(); } } }