开发者

How to see queries being fired by hibernate?

开发者 https://www.devze.com 2023-01-29 08:55 出处:网络
How do I see what queries are being fired by hibernate when a hibernate application is running in tomc开发者_StackOverflow社区at?The fast answer is

How do I see what queries are being fired by hibernate when a hibernate application is running in tomc开发者_StackOverflow社区at?


The fast answer is

hibernate.show_sql=true 

e.g. as in http://www.javalobby.org/java/forums/t44119.html

And from the official documentation:

hibernate.show_sql

Writes all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug. e.g. true | false

hibernate.format_sql

Pretty print the SQL in the log and console. e.g. true | false

See this question as well: Hibernate show real SQL


Also, if you want to show the value of your parameters you can add

log4j.logger.org.hibernate.type=trace

to your log4j properties file.


Another alternative is P6Spy. It intercepts the JDBC driver and logs all transactions.

http://sourceforge.net/projects/p6spy/

0

精彩评论

暂无评论...
验证码 换一张
取 消