• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help, how config Hibernate to show the real SQL?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know I can change property

hibernate.show_sql true

to show part of the SQL as

update SEQUENCE set I_SEQ=?, C_UPDATE_UID=?, T_STMP_UPD=? where C_TABLENAME=? and C_COLNAME=?

But is there anyway to show the real value instead of question mark?

Thanks in advance.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Directly below that debug Hibernate should be logging what values it is replacing the question marks with.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From this thread, you need to change one class's log level to DEBUG:Why this isn't another option, like "show_sql_params" beats me.

Another option is to use the P6Spy JDBC driver wrapper. It logs all SQL, including result sets, to a log file.
 
sam joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No luck, I still get the same thing. Here is my log4j.properties, is there something wrong with those parameters?
=========================================
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

#log4j.logger.net.sf.hibernate=info
log4j.logger.net.sf.hibernate=debug

### log just the SQL
#log4j.logger.net.sf.hibernate.SQL=debug

### log JDBC bind parameters ###
#log4j.logger.net.sf.hibernate.type=info
log4j.logger.net.sf.hibernate.type=debug

### log schema export/update ###
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug

### log cache activity ###
#log4j.logger.net.sf.hibernate.cache=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace
[ January 11, 2005: Message edited by: sam joe ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That file looks correct. Is there another log4j.properties file (in a JAR or elsewhere) that is taking precedence? I just tried it myself (with debug in both lower- and uppercase) and it works for me.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I set "log4j.logger.net.sf.hibernate.type=debug",

my console will show
Hibernate: insert into UsrGroup (name, description, status) values (?, ?, ?)
16:45:28,822 DEBUG StringType:46 - binding 'GroupName-199' to parameter: 1
16:45:28,822 DEBUG StringType:46 - binding 'Groupdescription' to parameter: 2
16:45:28,822 DEBUG IntegerType:46 - binding '1' to parameter: 3


If you have problem, you can try run a testcase in IDE with a log4j.properties in classpath. Thanks for you help.
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sql one:

Welcome to Java Ranch! Please change your display name here. It should conform to the JavaRanch Naming Policy (We are looking for a name that is not obviously fictitious...)
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that this question is a bit old. But just wanted to post the answer in case someone else needs it.

One can set the logging level to "TRACE", if "DEBUG" is not working in the following property of log4j:

log4j.logger.org.hibernate.type=TRACE
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And while we're on the topic, I found this file provided VERY verbose logging:


### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'debug' to 'debug' ##

log4j.rootLogger=debug, file
log4j.logger.net.sf.hibernate=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace

### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=debug

### log prepared statement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=debug

 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic