-->
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.  [ 4 posts ] 
Author Message
 Post subject: I've looked and looked - hibernate to print sql parameters?
PostPosted: Sat Nov 25, 2006 3:20 pm 
Newbie

Joined: Sat Nov 25, 2006 2:56 pm
Posts: 11
It's easy to get hibernate to print the sql, but I really need hibernate to print the parameters in the sql.

The only sql I can get printed is something like this:
Code:
insert into test_results (dateCompleted, student_id, test_id) values (?, ?, ?)


Where rather than showing the parameter values, there's just a bunch of "?" symbols. I'm using the latest version of hibernate 3.2.1.

I've tried adding these to my hibernate.cfg file, but they only make the sql prettier -
Code:
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.generate_statistics">true</property>


I've turned on the highest level of logging at startup, but that doesn't print the params either:
Code:
Logger logger = Logger.getLogger("org.hibernate.SQL");
logger.setLevel(Level.FINEST);


The only thing I've been able to find in the hibernate docs is this section on logging:
http://www.hibernate.org/hib_docs/v3/re ... on-logging

I've tried:
Code:
Logger logger2 = Logger.getLogger("org.hibernate");
logger2.setLevel(Level.FINEST);


and

Code:
Logger logger2 = Logger.getLogger("org.hibernate.type");
logger2.setLevel(Level.FINEST);


But those don't do it either.

I've even tried setting my MySQL database to log sql statements, but unfortunately the log file doesn't contain statements that weren't successful. (Bizarrely.)

If anyone knows how to get those sql parameters to print, could you please let me know how? I've put in a lot of work trying to track it down, but sadly, I just can't figure it out...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 25, 2006 6:25 pm 
Newbie

Joined: Wed Nov 22, 2006 5:09 pm
Posts: 8
Setup log4j and look for the bind statements that bind the data to the
appropriate positions. It *does* show this.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 25, 2006 6:35 pm 
Newbie

Joined: Sat Nov 25, 2006 2:56 pm
Posts: 11
versoft - Thank you for posting - that worked for me.

On a side note, I wish there was just a property in the hibernate config file to turn this on. Seems like it would be a lot easier.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 25, 2006 6:35 pm 
Newbie

Joined: Sat Nov 25, 2006 2:56 pm
Posts: 11
Double post


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.