One approach which works well for this type of thing is where you query
the values after you've done the update or insert and just populate the
changed properties in your instance.  LC DS lets the assembler modify
properties which are not defined on the client.  The most common example
is that you often set identity properties in your "createItem" method
after they are assigned in the database.  You also can do this for
version properties which get updated on each change though and certainly
a "last modified" timestamp would work this way.  In your createItem
method you do not need to do anything other than updating the property
in the instance passed in as it picks up any changed properties.  In the
updateItem method, you do need to ensure the changed property is in the
"changes" list passed to your assembler (or just add it if it is not).  

 

Since you are using the hibernate assembler, you'd probably need to
sub-class the hibernate assembler and put this logic into the subclass
after performing the create/update using the super class.  

 

The other way people use triggers is to modify rows or columns that
store data for unrelated objects... for that you'd have to use the
DataServiceTransaction api in Java to mirror what is being done in the
database if you want clients to track those changes.  Unfortunately that
means that you have to mirror the trigger logic in Java.   There's no
easy way that I know of to have the trigger notify the Java code so this
can be done automatically.  

 

Jeff

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Kevin
Sent: Monday, February 11, 2008 1:10 PM
To: [email protected]
Subject: [flexcoders] LCDS and triggers, auto inserts or updates of
timestamp columns

 

I am wondering how successful triggers are when used with LCDS & DMS?
Should I expect to run into a bunch of DataService conflicts with
this or are they safe to use. I am not thinking about anything too
crazy, even just basic timestamp updating would be nice to implement
on the database rather than in Java or on the client. There are some
basic triggers I would love to enable as well. 

Just looking for some quick opinions/advice before I enable these on
my database.

Thanks, Kevin

 

Reply via email to