# \`SqlStatementLogger\` produce the warning log

**URL:** <https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824>\
**Category:** Hibernate ORM\
**Created:** [June 15, 2023, 3:13am UTC](https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824 "2023-06-15T03:13:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![minjun\_jo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/minjun_jo/32/2493_2.png) [@minjun\_jo](https://discourse.hibernate.org/u/minjun_jo)\
**Post date:** [June 15, 2023, 3:13am UTC](https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824/1 "2023-06-15T03:13:04Z")

</div>

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.

```sql
(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

> **[GitHub - jo-minjun/SqlStatementLogger-warn-reproduce: reproduce the warning log](https://github.com/jo-minjun/SqlStatementLogger-warn-reproduce)**
>
> reproduce the warning log. Contribute to jo-minjun/SqlStatementLogger-warn-reproduce development by creating an account on GitHub.

```shell
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]

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [June 16, 2023, 7:26am UTC](https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824/2 "2023-06-16T07:26:26Z")

</div>

Update to Hibernate 6.2.5.Final

---

<div class="post-metadata">

**Author:** ![minjun\_jo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/minjun_jo/32/2493_2.png) [@minjun\_jo](https://discourse.hibernate.org/u/minjun_jo)\
**Post date:** [June 20, 2023, 1:57pm UTC](https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824/3 "2023-06-20T13:57:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [June 20, 2023, 4:22pm UTC](https://discourse.hibernate.org/t/sqlstatementlogger-produce-the-warning-log/7824/4 "2023-06-20T16:22:54Z")

</div>

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.
