O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logging the Hibernate-Generated SQL

In some situations, using an HQL or Criteria query may not provide what you want, or you may not know how changing the HQL or Criteria query will affect results. In such cases, you can configure Hibernate to show the generated SQL in a log file, or in the application console. A query analyzer can then trace or analyze the generated SQL.

The simplest way to show the generated SQL is by setting hibernate.show_sql in the configuration properties file, or show_sql in the configuration XML file, with true. You can also forward the generated SQL in the log files by setting up Log4j to debug. Besides, there are specific categories for the SQL log output, providing full control on the SQL logging. To learn more about ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required