Background: project development needs.
1 operation
Just add the following two lines of code to the Log4j.properties
#输出sql语句到日志 Log4j.logger.org.hibernate.SQL=Debug #将对应的参数占位符? Replace with incoming parameter log4j.logger.org.hibernate.type=trace
Experimental results:
.- the- to -:Wuyi: -[dubboserverhandler-thread-1] DEBUG Org.hibernate.SQL (104) -Selectcpsysparm0_. CODE ascode65_0_, Cpsysparm0_.name asname65_0_, cpsysparm0_. Parmvalue asparmvalue65_0_, cpsysparm0_. Parmdesc asparmdesc65_0_, cpsysparm0_. Modifiable asmodifiable65_0_, cpsysparm0_. Viewable asviewable65_0_, cpsysparm0_. Operuser asoperuser65_0_, cpsysparm0_. Opertime asopertime65_0_ fromcp_sysparm cpsysparm0_wherecpsysparm0_. CODE=? .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicBinder ( the)-Binding parameter [1] as[VARCHAR]-012 .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [current matches] ascolumn [name65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [1] ascolumn [parmvalue65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [NULL] ascolumn [parmdesc65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [0] ascolumn [modifiable65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [1] ascolumn [viewable65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [init] ascolumn [operuser65_0_] .- the- to -:Wuyi: -[dubboserverhandler-thread-1] TRACE Org.hibernate.type.descriptor.sql.BasicExtractor ( the)-Found [ .- One- at Ten: .:47.0] ascolumn [opertime65_0_]
You can see that the process and results of the query are output.
How to print hibernate-generated SQL statements to a log file