I want to do audit logging generated SQL statements in Hibernate. I wrote Custom Interceptor that extents EmptyInterceptor. I overrided onPrepareStatement method to get generated SQL. But When I debug this code I am only getting generated SQL without parameters like this.
INSERT INTO TableA(Col1,Col2,Col3) VALUES(?,?,?)
How can I get full SQL statement that contains parameter values like this from Hibernate
INSERT INTO TableA(Col1,Col2,Col3) VALUES('Value1','Value2','Value3')
In hibernate cfg, you may set hibernate.show_sql property to true, this will cause Hibernate to output the perpared statements (without the parameter values bound to a query) to stdout.
To have the precompiled statements and list of parameters bound to them logged, set log4j.logger.org.hibernate.SQL=DEBUG in your commons-logging (or underlying log system) configuration.