You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Dave Hahn <dr...@yahoo.com> on 2003/10/15 00:15:34 UTC

Using save() and audit trails

Sorry if this has been brought up before.  I like the clean interface
for Torque, but have an audit trail requirement I'd like to know if
there is a solution for using Torque.  This is a legacy system I'd like
to interface to.

Upon any insert, save, or delete of an object, I need to also log
column values to a normalized audit trail table.

In SQL terms, consider this update:

  update A set a1=v1, a2=v2 where rec_id=1

causes 

  insert into audit values ('A', 1, 'a1', old_a1, v1)
  insert into audit values ('A', 1, 'a2', old_a2, v2)

as part of the save transaction.


It seems I could accomplish this if there is some callback mechanism,
and I can get at column values that have changes between the persisted
version of the object and the currently being saved object.  Can this
be accomplished?  Any hints on how?

Thanks in advance.

Dave Hahn


=====
Dave Hahn
drhahn95@yahoo.com

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Using save() and audit trails

Posted by Scott Eade <se...@backstagetech.com.au>.
Dave Hahn wrote:

>Sorry if this has been brought up before.  I like the clean interface
>for Torque, but have an audit trail requirement I'd like to know if
>there is a solution for using Torque.  This is a legacy system I'd like
>to interface to.
>
>Upon any insert, save, or delete of an object, I need to also log
>column values to a normalized audit trail table.
>
>In SQL terms, consider this update:
>
>  update A set a1=v1, a2=v2 where rec_id=1
>
>causes 
>
>  insert into audit values ('A', 1, 'a1', old_a1, v1)
>  insert into audit values ('A', 1, 'a2', old_a2, v2)
>
>as part of the save transaction.
>
>It seems I could accomplish this if there is some callback mechanism,
>and I can get at column values that have changes between the persisted
>version of the object and the currently being saved object.  Can this
>be accomplished?  Any hints on how?
>  
>
Torque does not provide a specific solution to your problem.  You could 
I guess modify the velocity templates used to generate your OM classes 
to write the audit records, but it would probably be a fair chunk of 
work and you would need to re-do it each time you upgrade Torque 
versions.  Perhaps a simpler approach would be to modify the torque 
templates to provide the desired callbaback only - at least this would 
minimise the maintenance necessary when upgrading versions.

HTH,

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au





---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org