This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes hibernate sql logging with param value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate sql logging with param value" Watch "hibernate sql logging with param value" New topic
Author

hibernate sql logging with param value

Krishnaa Kumar
Greenhorn

Joined: May 05, 2011
Posts: 25
Hi.,

Its known that setting show_sql=true logs all the sql queries.
Is it possible to LOG THE VALUES passed to the sql query?

With Thanks,
Krishna.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

...Is it possible to LOG THE VALUES passed to the sql query?

Of course you can log the variables being passed to the query just before you call any method which would generate the SQL.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Hibernate uses prepared statements so what you probably expect, a complete string of SQL with the parameters filled in, is not possible because it does not exist at any time. But if you set the log level for org.hibernate.type to TRACE you will get the binding of parameters in the log.
 
Don't get me started about those stupid light bulbs.
 
subject: hibernate sql logging with param value