-->
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: How to get SQL statements
PostPosted: Tue Aug 12, 2008 5:38 am 
Newbie

Joined: Tue Aug 12, 2008 5:06 am
Posts: 2
I have an DAO called entityDAO with methods: persist, save, delete.
The content of these methods is just using some api of hibernate to work with objects.
The problem is how to get sql statements after these methods are executed:
example:

entityDAO.persist(object)

---> the sql statement will be: INSERT INTO .....VALUE....

I want to get all sql statements and save to database for tracking.

Please kindly give me solutions.

Thanks


Last edited by vodka on Tue Aug 12, 2008 6:03 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 5:44 am 
Newbie

Joined: Thu Aug 07, 2008 4:23 am
Posts: 5
Hibernate API Methods dont give you access to the statement objects the whole point is to abstract above these.

Not sure why you would want to track these, Maybe you just want to log the sql that is generated but turning on that property in your hibernate.properties file?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 2:12 am 
Newbie

Joined: Tue Aug 12, 2008 5:06 am
Posts: 2
As mentioned above, i want to store all sql statements executed in system.
Anyway, thanks for your answer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 2:16 am 
Newbie

Joined: Fri Jan 25, 2008 6:17 pm
Posts: 2
Location: Pune, MH, India
vodka>
Quote:
The problem is how to get sql statements after these methods are executed

smolka>
Quote:
Hibernate API Methods dont give you access to the statement objects the whole point is to abstract above these.


I think vodka just wants to see the hibernate generated sql statements (not the Statement object as in JDBC). If i got it right then all you need to do is put

Code:
log4j.logger.org.hibernate=INFO
log4j.logger.org.hibernate.type=DEBUG

in your log4j.properties and
Code:
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="use_sql_comments">true</property>

in your hibernate.cfg.xml

Hope it helps :)

cheers

_________________
Kunal


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.