-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: logging sql, can I get rid of ?, ?, ?
PostPosted: Sun Apr 23, 2006 7:56 am 
Regular
Regular

Joined: Thu Sep 16, 2004 4:56 pm
Posts: 80
The logging of sql statements seems to be real nice except for when it runs inserts/updates, it logs stuff like this....

Code:
Hibernate: insert into Parents (name, Version, Id) values (?, ?, ?)
Hibernate: insert into Children (name, parent_id, Version, Id) values (?, ?, ?, ?)
Hibernate: insert into Children (name, parent_id, Version, Id) values (?, ?, ?, ?)
Hibernate: update Parents set name=?, Version=? where Id=? and Version=?


I want to see what was inserted or what those question marks really are. Is there a way to change that? I am especially trying to figure out why that last update was run....the three inserts should have been enough.
thanks,
dean


Top
 Profile  
 
 Post subject: Re: logging sql, can I get rid of ?, ?, ?
PostPosted: Sun Apr 23, 2006 11:33 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
deanhiller wrote:
The logging of sql statements seems to be real nice except for when it runs inserts/updates, it logs stuff like this....

Code:
Hibernate: insert into Parents (name, Version, Id) values (?, ?, ?)
Hibernate: insert into Children (name, parent_id, Version, Id) values (?, ?, ?, ?)
Hibernate: insert into Children (name, parent_id, Version, Id) values (?, ?, ?, ?)
Hibernate: update Parents set name=?, Version=? where Id=? and Version=?


I want to see what was inserted or what those question marks really are. Is there a way to change that? I am especially trying to figure out why that last update was run....the three inserts should have been enough.
thanks,
dean


the question marks are placeholders for the values, because hibernate is using PreparedStatement's internally. AFAIK it's impossible to let the values show.
to track down what your app is doing you should start your debugger.

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 2:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dudes - you need to read the manual.

http://www.hibernate.org/hib_docs/v3/re ... on-logging

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 7:23 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
I haven't used HB in a while, so I haven't checked out any of the new logging options; but when I needed to do stuff like that I used to use a product called P6Spy (it's not actively supported anymore but will still work for what you want to do).

It outputs the sql with the positional markers (the "?" characters) replaced with the values that were passed to the JDBC call.

Even if the newer HB formatting options do what you want, this can still be a useful option. With correct configuration, it works for direct SQL that was not issued using the Hibernate API At all.

http://sourceforge.net/projects/p6spy/

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 1:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
1) they are not new logging options (they have been there since forever)

2) p6spy and similar technologies is also very much recommended since it works across hibernate and non-hibernate access. (but requires a little more setup than just enable a logging level)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 10:13 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
max wrote:
dudes - you need to read the manual.

http://www.hibernate.org/hib_docs/v3/re ... on-logging


that'a helpfull hint, really!

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.