Wednesday, September 07, 2011

Tracking Hibernate SQL query and parameters

Every developer using Hibernate might need to know the SQL it generates and the parameters being sent. Normally to have the sql printed out to console, one only have to configure hibernate property show_sql to true. However the parameters are not printed out.

Luckily for me, I found this post on configuring the necessary log level to be able to print out the sql and parameters. Here are the configuration that I used:

<logger name="org.hibernate.sql">
<level value="debug" />
<appender-ref ref="console"/>
</logger>

<logger name="org.hibernate.impl.SessionImpl">
<level value="debug" />
<appender-ref ref="console"/>
</logger>

<logger name="org.hibernate.engine.QueryParameters">
<level value="debug" />
<appender-ref ref="console"/>
</logger>

<logger name="org.hibernate.type">
<level value="debug" />
<appender-ref ref="console"/>
</logger>


For the moment, I think these satisfy my need :)

No comments: