TopLink Wiki

Main
About
Javadoc
Forum
Resources

RecentChanges
About Wiki
Find Pages
Page Index

Set your name in
UserPreferences

Edit this page


Referenced by
UpdateLastModifiedBy
UpdateModifiedBy
UpdateCreatedBy
InsertCreatedBy




JSPWiki v2.0.52


AutoUpdateLastModifiedBy


Can TopLink auto-update lastModified (timestamp) and lastModifiedBy (userID) fields on every object? (also known as Poor Man's audit trails).

Quick answer:

Register an aboutToUpdate event listener like the following:

public void toplinkAboutToUpdateEventHandler(DescriptorEvent event)
{
    event.updateAttributeWithObject("myTimestamp", new Date());
    event.applyAttributeValuesIntoRow("myTimestamp");
    etc.

I do not recomment you use the preUpdate or preWrite events for this purpose as they can be fired even though the object has no changes and does not require updating!

For created and createdBy fields, register an aboutToInsert event. Note that I ran into problems with the TopLink903 aboutToInsert event; I had to use the preInsert event instead.

Long Answer:

forum:276175


Edit this page   More info...   Attach file...
This page last changed on 15-Apr-2005 13:55:00 PDT by 64.168.145.189.