-->
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.  [ 2 posts ] 
Author Message
 Post subject: Monitoring: how to get hibernate generated sql for monitor?
PostPosted: Tue Dec 09, 2003 9:34 pm 
Beginner
Beginner

Joined: Wed Oct 08, 2003 4:22 pm
Posts: 29
We have a monitor that displays stats for every sql statement executed on our system. When a query starts the monitor displays "STARTING <sql> at <time> ..."

When the query completes the monitor displays "COMPLETED <sql> Duration <duration> ..."

I know Hibernate has a show_sql flag to have it log its sql. But is there a programmatic way to get the generated sql, so that I can do something like (main desire is to put entry at start-query, and then update entry at end-query):

Code:
   Session session = getHibernateSession();

   myMonitor.addEntry( session.createCriteria(klass).getGeneratedSQL(), getTime() );

   List list = session.createCriteria(klass).list();

   myMonitor.updateEntry( session.createCriteria(klass).getGeneratedSQL(), getTime() );




Cheers
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 10:17 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
I don't think you can do that programmatically, but you could perhaps use p6spy to produce sql log output . One of the things P6Spy outputs is the execution time for a query.

You could then parse the logs and get the query and execution time. Or write your own log4j appender to capture the log statements as they happen and do what you need with them right then.

P6Spy is available at http://www.p6spy.com/ .

Daniel


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