Because of the ORM tool, we debug the program is far from directly in the program to write a string of SQL simple, want to check a SQL is how happy, a line of sql = "SELECT * From ..." Look for it, now with Hibernate, Even if the show_sql=true is opened in JPA, it is a string called "name =?" and id =? "
Fortunately find a tool, P6spy, as a real JDBC agent, intercept all SQL, let us see a real SQL opportunity. Download First, the following configuration defaults to the same as my current project
Hibernate+proxool+postgresql the deployment level after the change is Hibernate+proxool+p6spy+postgresql
After the P6spy download, unpack the jar package, the steps are simple:
- The P6spy.jar is placed under the web-inf/lib of the Web program.
- Spy.properteis into the web-inf/classess.
Spy.properties to change the following properties:
Realdriver=org.postgresql. Driver //True JDBC driver name deregisterdrivers=Trueappender= Com.p6spy.engine.logging.appender.StdoutLogger //output to the console
Then change the configuration of Proxool connection pool, replace the real JDBC driver with P6spy, as an intermediary agent, intercept SQL
Proxool.properties
Jdbc-0.proxool.driver-class=com.p6spy.engine.spy.p6spydriver
The configuration is complete, open the IDE and admire the long-lost SQL statement.