Tip: Logování SQL v Hibernate

Pokud potrebuju logovat SQL v Hibernate spolecne s parametry, muzu pouzit P6Spy.

Ale mnohem jednodušší je použít Log4j 🙂 :

log4j.logger.org.hibernate.SQL = DEBUG
log4j.logger.org.hibernate.type = TRACE

Přiklad vystupu hibernate:

7820 DEBUG [org.hibernate.SQL] {main} - insert into Client (name, personalNumber, id) values (?, ?, ?)
7821 TRACE [org.hibernate.type.StringType] {main} - binding ‘John Doe’ to parameter: 1
7821 TRACE [org.hibernate.type.StringType] {main} - binding ‘123X’ to parameter: 2
7821 TRACE [org.hibernate.type.LongType] {main} - binding ‘10′ to parameter: 3

Napsat komentář

This site uses Akismet to reduce spam. Learn how your comment data is processed.