-->
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.  [ 6 posts ] 
Author Message
 Post subject: Feature Suggestion: Automated Applicaiton of Audit Patterns
PostPosted: Mon Jan 16, 2006 12:48 am 
Newbie

Joined: Mon Jan 16, 2006 12:08 am
Posts: 1
Location: Canberra, Australia
Disclaimer: A possible 'enhancement request' for Hibernate came up in a discussion the other day, but I have not had time to think through all the issues to decide if it made sense or not. So, rather than clutter JIRA with a nebulous idea, I thought it woud be more appropriate to post it to a forum for discussion. Let me know if this is the wrong way to go about it.

-------------------------------

In the December issue of Dr. Dobb's Journal, Todd Schraml has an article entitled Table Patterns and Changing Data: Dealing with History in Relational Databases. At first glance, he seems to have captured each of the basic database 'patterns' used to provide history/audit trails within business applications, along with some useful heuristics for when to use what. For example, he compares and contrasts the common 'functional history' table with 'row-level audit' and 'column-level audit' patterns.

My experience is that this is an area of database design that is opaque to most Java developers (unless, of course, they come from a DBA background). Heck, even most BA's I've worked with seldom think to ask about auditability requirements unless you point them in that direction. That's a problem, especially in the US where SOX compliance is becoming a huge issue. That got me thinking...

Automating the application of these 'database design patterns' via Hibernate would go a long way to solving the problem. It would raise awareness among developers of the issues and solutions. It would also ease resistence to discussing or implementing audit requirements because automated application of the most common patterns by Hibernate would make the implementation trivial for the application dev.

As a straw man, let's assume you are going the annotations route. Imagine applying an attribute something like the following:

@Auditable(type = "history table")
public class Foo {
...
}

And this results in Hibernate creating an associated history table for the table structure it creates to store 'Foo'.

Now, I'm aware that Hibernate will allow you to implement audit logging using interceptors (see Hibernate in Action pp. 340-347 for details) but 'audit logging' is not the same as an 'auditable table structure', although they are used for related purposes. 'Hard' auditability requirements (e.g. those imposed by SOX) are likely to drive databse design toward the patterns described by Todd Schraml rather than the use of the (simpler to create, but harder to report against) audit logs. Or so I would argue.

If true, my (perhaps naive) perception is that these designs woud be labourious to create/use with 'standard' Hibernate usage patterns. Is this true, or is there some dirt simple implementation approach I'm just not aware of yet? If it is true, this seems to me to be an area that could be effectively automated by Hibernate, shielding the developer from the details of the necessary changes to the DDL and the insert and update semantics.

Thoughts?

_________________
Cheers,
Christopher

Christopher J. Rodrigues Macias
Enterprise Architect
QCOM/Unisys


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 10:44 pm 
Beginner
Beginner

Joined: Mon May 09, 2005 5:26 pm
Posts: 21
As it happens, I'm a Java developer fitting the description. I too read the Dr. Dobbs article and put it in the back of my head for a "to-do" on my current hibernate-enabled project.

I'm at the point now where the history/audit functiionality needs to be implemented and came across this post while searching for a solution. I'd love it if Hibernate "just worked" for auditing, but I suspect that's a long way off...

So, has anyone implemented history/audit tables w/ Hibernate? Any recommendations as to how to procede?

thanks,

-don.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 12:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The Wiki has examples as does HIA. Then again you could just let the database do it, eg, use triggers .


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 11:12 pm 
Beginner
Beginner

Joined: Mon May 09, 2005 5:26 pm
Posts: 21
David,

I assume you're referring to:
Audit Logging -- http://www.hibernate.org/318.html and
History Interceptor -- http://www.hibernate.org/195.html

which discuss how to create an audit log, but I've found nothing that speaks to how to use the log. I understand how to use triggers or Hibernate's Interceptor to stuff the needed data into the DB, but writing a Hibernate-based app to traverse it isn't so clear.

Also, they both refer to a single pattern (that of the audit log), wheras the article in question (and a decent overview by Martin Fowler at http://martinfowler.com/ap2/timeNarrative.html), give other "audit-like" patterns. I'm specifically interested in Fowler's "Snapshot" pattern. (though I'm sure other folks need the other patterns here) I'm curious if anyone has been able to find a slick way of getting Hibernate to help.

thanks all,

-don.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 6:19 am 
Beginner
Beginner

Joined: Fri Oct 28, 2005 7:11 am
Posts: 20
We also need good history tables: to store all changes in transaction, and whats more diffucult to retrieve the changes done during transaction and in proper order - and it could be hundrets of objects, main-collection-collection, references and inheritance together.
Basicaly any DB depended stuff is rejected due to our design. So we try to do it purely in Hibernate using events. Seems to be hard stuff to write, but now looks like we are close to succeed.
btw we had 5 years ago, a c++ db persistance which had history implemented in the box, and we were slightly dispointed, that such feature is not in Java persistence frameworks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 10:25 am 
Newbie

Joined: Thu Apr 06, 2006 4:36 pm
Posts: 2
ChristopherRM,
I agree that a user should be able to mark an object Auditable, and I have a suspicion that this feature could be implemented with a cleverly written custom persister, and therefore not requiring much in the way of changes to the Hibernate core.

Let me just go on the record throwing my vote in for an implementation of a simple row-level audit.


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