In the hibernate.cfg.xml configuration file, setting show_sql to true will display SQL statements on the console. However, this is not the "real" SQL passed to the database. Is it possible to get the original SQL query?
Yes, there are two ways to get the raw SQL query:
JDBC Driver Proxy:
Use a JDBC driver proxy such as P6Spy or log4jdbc. These tools intercept SQL commands sent to the database and provide detailed information, including the actual SQL query.
Hibernate logging:
Enable logging for the following categories:
<code>log4j.logger.org.hibernate.SQL=DEBUG log4j.logger.org.hibernate.type=TRACE</code>
The above is the detailed content of How Can I View the Actual Raw SQL Queries Executed by Hibernate?. For more information, please follow other related articles on the PHP Chinese website!