I'm deploying an EAR to Websphere Liberty 21.0.0.6 with persistence provider Hibernate 5.4 (my problem persists in version 5.5). Database is Oracle 12c.
I activated Hibernate's feature of logging slow sql queries via persistence.xml (https://docs.jboss.org/hibernate/orm/5.5/javadocs/org/hibernate/cfg/AvailableSettings.html#LOG_SLOW_QUERY)
The setting is working, but unfortunately, Liberty has a prepared statement wrapper that has no sensible toString() method. So the output in my logs is
org.hibernate.SQL_SLOW: SlowQuery: 3299 milliseconds. SQL: 'com.ibm.ws.rsadapter.jdbc.v42.WsJdbc42PreparedStatement@229da89'
org.hibernate.SQL_SLOW: SlowQuery: 2230 milliseconds. SQL: 'com.ibm.ws.rsadapter.jdbc.v42.WsJdbc42PreparedStatement@90069551'
and so on. Which doesn't help much in figuring out which queries are slow... Seems so that Hibernate just does a toString() on the prepared statement. See the source of org.hibernate.engine.jdbc.spi.SqlStatementLogger#logSlowQuery(Statement, long).
- Is there a possibility to configure hibernate or liberty to output the real SQL? Do I have to implement an own statement wrapper?
- Should I open a bug in hibernate?