views:

590

answers:

1

I want to log all changes in my database for auditing purposes, using a table called AuditEvent that stores the modified row ID (primary key), table name, column name, previous value, new value, date of change (timestamp), operation type (insert / update / delete) and the name of the user who did the changes.

I'm using SQL Server 2005, but I don't want to use triggers, because since I use a connection pool it would be difficult to find the current user.

The Hibernate solution based on an Interceptor is pretty simple. How do I do something similar when using iBATIS / iBATOR ?

A: 

If you're using spring, you might be able to use SqlMapClientDaoSupport to write template Dao objects that wrap auditing up with whatever transaction support you are using. If not, there is an iBatis Doa template option, iBatis DAO. That has been depreciated so you might be better off with Spring.

sal
I already have DAOs generated by iBator, but they don't help at all, since they don't provide any aspect-oriented facilities, being necessary to code everything manually.That's was my solution, BTW: custom code at the DAOs, that use reflection to find and log the modified attributes of the inserted / updated objects.
muriloq
@muriloq no idea if this is possible, but you might want to look at Springs AOP support. The transaction example could be useful for auditing.
sal