-->
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.  [ 3 posts ] 
Author Message
 Post subject: How can I get SQL text when using Hibernate
PostPosted: Wed Aug 29, 2007 11:21 am 
Newbie

Joined: Sun Jul 01, 2007 9:52 am
Posts: 2
I am using hibernate for persistence data, but unfortunatelly I had to save the data by myself for my special project. Every save/update/delete operation I should get the SQL and save them to the text files. And I have two problems:
1. How can I get the SQL from Hibernate.Session.save / update / delete in application? The option <show_sql>true</show_sql> just control hibernate to write the SQL to the log files, I didn't want to analyse the log files to get the SQL.
2. If can't get the SQL file, so I just save the Object and if there are a Set in the persistence object, did all the data in the Set will be saved?

Thanks all very much.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 02, 2007 4:18 pm 
Newbie

Joined: Sun Sep 02, 2007 1:20 pm
Posts: 5
You could use log4j to configure a separate appender only for the logger org.hibernate.SQL. That way you have all SQL statements in one file.

But I'm sure that is not what you want, because you will only have the statements, not the parameter values.

So I would suggest log4jdbc [http://log4jdbc.sourceforge.net/]. It's a proxy JDBC driver that is capable of logging all JDBC statement passing through. That way you should be able to get both, statements and parameters values.

Hope that helps a bit.

_________________
-alf


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 02, 2007 4:46 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
org.hibernate.Interceptor.onPrepareStatement()

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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