You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Ron Gallagher <rg...@bellsouth.net> on 2003/09/19 03:04:49 UTC
Re: How to Set Last Updated Time Automatically?
Gene --
There are two interfaces designed to handle this situation: org.apache.ojb.broker.PBLifeCycleListener and org.apache.ojb.broker.PersistenceBrokerAware.
The PBLifeCycleListener interface can be used by any object. Just implement the interface in your class and register it as a listener with the PersistenceBroker. PBLifeCycleListener includes two methods, beforeInsert and beforeUpdate, that are well suited for your situation.
The PersistenceBrokerAwareinterface is intended to be used by a persistence-capable class. PersistenceBrokerAwareinterface defines two methods with the same names that can also be used in your situation.
Ron Gallagher
Atlanta, GA
rongallagher@bellsouth.net
> From: "Gene Qian" <ge...@hotmail.com>
> Date: 2003/09/18 Thu AM 01:13:59 EDT
> To: ojb-user@db.apache.org
> Subject: How to Set Last Updated Time Automatically?
>
> Hi,
>
> I have a persistent field, say, lastUpdated(column is
> LAST_UPDATED_DATETIME), which is used to store last updated time of the db
> record. My question is: Can we use OBJ automatically set and store the field
> with right datetime when the persistent object was stored to DB with any
> field value changed? If so, how to do?
>
> Any comments will be appreciated.
>
> Gene
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org