-->
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.  [ 8 posts ] 
Author Message
 Post subject: Auditing Selects
PostPosted: Mon Jan 26, 2004 5:17 am 
Newbie

Joined: Mon Jan 26, 2004 5:09 am
Posts: 2
We have a requirement that all database selects must be logged and cannot see any obvious method for achieving this. The onLoad() interceptor method appears to log object loads but not reads of individual columns from HQL queries.

If anyone has successfully implemented a method of doing this perhaps by logging the sql itself or by some other method I would be very grateful for any pointers as to how to go about it.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 9:09 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Why not using the features of your JDBC driver ? Many driver can log everything they do.

If yours doesn't do it, then try P6Spy...

Another approach is to raise Hibernate's debug level and set the showSql property to true.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 10:25 am 
Newbie

Joined: Mon Jan 12, 2004 3:25 pm
Posts: 9
when you say log, what do you mean by it. Log to a database, log to a file? log where?

If you need to log it to a file, show_sql=true will log your sql's to console. Otherwise I would dig up the code and see when and how the above mentioned log statements gnerated. After that my guess AOP will provide the fastes and least intrusive solution.

HTH,
Alex.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 10:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It doesn't log to the console. Hibernate logs to the place you configured, using either Log4j or JDK 1.4 logging. We even have a LogAppender (somewhere on the Wiki) that logs to a database, write your own to log your SQL in whatever way you need.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 6:40 pm 
Newbie

Joined: Fri Jan 23, 2004 12:16 pm
Posts: 5
Make sure you log to a file. Logging all selects to a database
can quicly limit your ability to scale and handle a large load.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 6:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, even logging to a file will harm performance. For a local database, I imagine that a write to disk is slower than querying from the database's cache.


Top
 Profile  
 
 Post subject: Auditing Selects
PostPosted: Wed Jan 28, 2004 11:00 am 
Newbie

Joined: Mon Jan 26, 2004 5:09 am
Posts: 2
Many thanks to all who replied. I am going to investigate P6Spy further as a first step.

Thankyou.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 6:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
asynchronous flush with file logging, can be a good way of improvement in this case.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.