Finding Hibernate Debugging Information

Possible duplicate:
Print a query string in sleep mode with parameter values

I use Hibernate as a save layer. And I set show_sql to true to view debug information.

However, in fact, I do not see the full information, because most SQL statements are like:

insert into Address (address1, address2, city, province) values (?, ?, ?, ?) 

all parameters are question marks, although I can see some factual data in some part of the condition of the select statement.

I want the information to be like:

 insert into Address (address1, address2, city, province) values ("XXX address1", "XX address2", "XXX city", "XXX province") 

How to configure viewing parameters of these parameters or is it a drawback in sleep mode ??

+2
source share
1 answer

Hibernate cannot register SQL and its parameters on the same line as you. Logging provided by Hibernate (by setting log4j.logger.org.hibernate.SQL=debug and log4j.logger.org.hibernate.type=trace in the log4j.logger.org.hibernate.type=trace configuration) can only log SQL, and parameters on different lines will like:

 insert into Address (address1, address2, city, province) values (?, ?, ?, ?) binding parameter [1] as [VARCHAR] - xxxxxx binding parameter [2] as [VARCHAR] - xxxxxx binding parameter [3] as [VARCHAR] - xxxx 

You need to use the JDBC proxy if you want to register SQL with parameters in one line. I tried log4jdbc , and it can do this, and it can also write down the time spent by each SQL statement, and write lines to the code that invoke the SQL statements.

Further information can be found on this blog .

+5
source

Source: https://habr.com/ru/post/1340359/


All Articles