Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Suggestions on how to keep a SQL non-select user audit trail
PostPosted: Sun Nov 19, 2017 9:40 am 
Newbie

Joined: Wed Nov 01, 2017 9:23 am
Posts: 2
Hi all

I am aware of and I am considering a couple of options for audit trail SQL.

Currently I am considering using:

1. Log4j2 writing an info log to a date based rolling log file when ever a non-select SQL jpa query is executed.
2. Still using Log4j2 as above, but instead of writing to a rolling log file, write the info logs to a separate (from the production Postgres datastore) Postgres datastore .
3. Manually call an insert jpa SQL command each time a DML call is made.

But for some reason I feel like there should be a more intuitive directly supported by the JPA specification (running on Wildfly, thus using Hibernate underneath) method of persisting all DML queries together with the details of the user account that executed the DML and the time stamp of execution, to a separate Postgres datastore.

Please provide feedback on what you suggest.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Suggestions on how to keep a SQL non-select user audit trai.
PostPosted: Sun Nov 19, 2017 9:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1590
Location: Romania
The best way to achieve this goal is to proxy the JDBC DataSource or the Driver as explained in this article.

With this approach, you can even detect N+1 query issues automatically during testing.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Suggestions on how to keep a SQL non-select user audit trai.
PostPosted: Sun Nov 19, 2017 10:30 am 
Newbie

Joined: Wed Nov 01, 2017 9:23 am
Posts: 2
vlad wrote:


Thanks, excellent link and information; most appreciated.


Top
 Profile  
 
 Post subject: Re: Suggestions on how to keep a SQL non-select user audit trail
PostPosted: Sun Nov 19, 2017 10:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1590
Location: Romania
You are very welcome.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.