`SqlStatementLogger` produce the warning log

Hello.
I am using Spring Boot 3 and JPA in my project.

I have used the spring.jpa.properties.hibernate.format_sql: true option for SQL log formatting.
and when using the following query with native query, SqlStatementLogger produce the warning log.

(SELECT * FROM a_entity a1)
UNION
(SELECT * FROM a_entity a2)
ORDER BY id ASC

Can you provide a solution or a patch for this issue?


The following warning log has occurred. and there is a repository for reproducing the warning log and trying

yyyy-MM-ddTHH:mm:ss.SSS+09:00  WARN 63191 --- [           main] org.hibernate.SQL                        : Couldn't format statement

java.lang.IllegalArgumentException: count is negative: -1
    at java.base/java.lang.String.repeat(String.java:4415) ~[na:na]
    at org.hibernate.engine.jdbc.internal.BasicFormatterImpl$FormatProcess.newline(BasicFormatterImpl.java:405) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
    at org.hibernate.engine.jdbc.internal.BasicFormatterImpl$FormatProcess.beginNewClause(BasicFormatterImpl.java:329) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
    at org.hibernate.engine.jdbc.internal.BasicFormatterImpl$FormatProcess.perform(BasicFormatterImpl.java:157) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
    at org.hibernate.engine.jdbc.internal.BasicFormatterImpl.format(BasicFormatterImpl.java:33) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
    at org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:123) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
    at org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:106) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]

Update to Hibernate 6.2.5.Final

I tried updating to 6.2.5.Final. But it’s still occurred. (I updated it on my repository)
If there is any update on this, please let me know.

The thing is, this is a warning log message, so theoretically you can just ignore that, especially since formatted logging is usually only a development time configuration, but if you care about this, you can create a JIRA ticket and attach the SQL query that fails to format.