Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.5k points)

if I set

<property name="show_sql">true</property>

in my hibernate.cfg.xml configuration file in the console I can see the SQL.

But it's not real SQL... Can I see the SQL code that will be passed directly to database?

Example:

I see

select this_.code from true.employee this_ where this_.code=?

Can I see

select employee.code from employee where employee.code=12

the real SQL?

1 Answer

0 votes
by (46k points)

Can I see (...) the real SQL

If you require to see the SQL sent straight to the database (that is formatted related to your example), you'll have to use any kind of jdbc driver proxy similar P6Spy (or log4jdbc).

Alternatively, you can permit logging of the following sections (using a log4j.properties file here):

log4j.logger.org.hibernate.SQL=DEBUG

log4j.logger.org.hibernate.type=TRACE

The first is equivalent to hibernate.show_sql=true, the second prints the bound parameters among other things.

For more check out 

Related questions

Browse Categories

...