db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: TIMESTAMP fields and doUpdate()
Date Wed, 24 Aug 2005 07:51:18 GMT




Hi,

I do not know a really clean way of doing it. You could not define the
field in the schema.xml and then add it by hand in the SQL script,
but then you cannot read the property in Torque.
In a database supporting Triggers, you could also setup a post trigger to
inserts which fills tthe fielad after an update (this would result in the
field being set twice.)
Then, there's the field type "Other", no idea what it does.

I would not recomment to overwrite the save method in order to not save the
timestamp (you would have to dig deep into the internals of Torque to do
that), but rather overwrite the save method to add the line
obj.setTimeStampField(new Date());

     Thomas

"Aaron Loucks" <aaronl@GardnerInc.com> schrieb am 23.08.2005 21:50:36:

> Is there a way to have Torque not set the value for a field declared as
> TIMESTAMP? It appears that saving an object or performing doUpdate(obj)
> will set the value of a timestamp field just as it would with any other
> field. Id much rather let the backing database change the value of the
> timestamp field rather than having to do something like:
>
>
>
> MyTorqueObject obj = MyTorqueBaseObject.retrieveByPK(x);
>
> obj.setSomeOtherField("a string value");
>
> obj.setTimeStampField(new Date());
>
> MyTorqueObject.save() ;
>
> /* or MyTorqueObjectBasePeer.doUpdate(obj) */
>
>
>
>
>
> I guess I could override the doUpdate() and save() methods but I'm
> hoping that I've overlooked something in the schema or runtime
> properties.. any suggestions?
>
>
>
> Aaron
>
>
>


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


Mime
View raw message