Saturday, April 14, 2007

Getting SQL statistics from Hibernate

It is important to be able to see the SQL queries hibernate is generating. There are two suitable options here:

  1. Get them via log4j: just add the following logger to the log4j properties file: "log4j.logger.org.hibernate.SQL=DEBUG, SQLappender", where SQLappender is a log4j appender defined somwhere else.
  2. Use the hibernate statistics package: there are some useful classes and interfaces under the org.hibernate.stat package which you can use to get query statistics (http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/package-summary.html)

Labels: , ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]