What you can do is store the original values from the select into a map with Apache BeanUtils.describe(object) and store that somewhere, e.g. in the session if a web application. Then, compare the values returned to the original. You can even dump the changed values into a map with BeanUtils.describe() and then just step thru both maps to do an automated comparison.
HTH, -ed On 2/15/06, Rashmi Dave <[EMAIL PROTECTED]> wrote: > > > > Hi Jeff, > > > > I started out thinking exactly the same and so did not see a problem with > the entire update. However, there are some fields in the table that are not > getting displayed. Now here, I need to fire a select, find out what the > current value is, and then put that value in the parameter object. Which > basically means an additional select per update. > > > > I will write a custom update for the last login date. Thanks a lot for your > help. > > > > Regards > > ~Rashmi > > > > ________________________________ > > > From: Jeff Butler [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 15, 2006 9:10 PM > > To: [email protected] > Subject: Re: Selective Update of fields depending on values in object > > > > > > Hi Dave, > > > > > > I understand the "last login date" requirement - I would write a custom > update for that requirement. > > > > > > For the other, I've always taken a different stance on these kinds of > things. It seems easier to me to update the whole record that do do the > dirty checking you would need to do to accomplish the selective update. The > problem is this - how do you know what fields have changed? If this is a > web app, then you would need to read the old record and do a field by field > check (or use some kind of JavaScript hack to set dirty flags). If it's not > a web app, then its certainly easier to manage the state - but you would > still have to do the dirty check or set dirty flags somehow. I've always > thought it was easier just to update the entire record. > > > > > > Just my thoughts - your experience may be different. > > > > > > Jeff Butler > > > > > > > > On 2/15/06, Rashmi Dave <[EMAIL PROTECTED]> wrote: > > > Hi Jeff, > > > > I have a form – Update Profile of the User. Here, I would like to update > only those columns that have changed. > > > > Also, when my user logs in, I want to update only the Last_Login_date field > of the user table. This is why I need it. > > > > Hope this clarifies. > > > > Regards > > ~Rashmi > > > > ________________________________ > > > From: Jeff Butler [mailto: [EMAIL PROTECTED] > Sent: Wednesday, February 15, 2006 7:25 PM > To: [email protected] > Subject: Re: Selective Update of fields depending on values in object > > > > > > Hi Dave, > > > > > > 1. You don't need to regenerate the maps if all you're changing is NOT NULL > to NULL. Abator doesn't care about the nullability of a column. But > regenerating the maps shouldn't be a big issue anyway - Abator was designed > so you could run it repeatedly without losing anything extra you've added. > > > > > > 2. You are correct that the update statement updates all columns. You'll > need to write custom update statements if you want to update a subset of the > columns. > > > > > > I think it is unusual to do selective column updates if you are working with > anything close to a rich domain model - I've never had that requirement on > any of my projects. That's why I didn't add support for it in Abator. I > suppose it wouldn't be that difficult to add if there is a general feeling > that it's needed. Does anyone else have any thoughts about this? > > > > > > Jeff Butler > > > > > On 2/15/06, Rashmi Dave < [EMAIL PROTECTED]> wrote: > > Hi All, > > We are using Abator generated SQL Map configuration files. I have two > questions > > 1. It turns out that a column in a table that I thought is NOT NULL, should > be a NULL column. I need to change the schema. Now do I need to re-generate > the SQL Maps again? (Please say I don't have to!!) Is there any information > regarding NULL/NOT NULL property stored? > > 2. The update query generated by Abator makes it compulsory for us to > update > all columns in the table. What do I need to do to selectively update? Can I > somehow reuse the same update generated and avoid writing a different > update > query per column? I hope this question isn't an obvious one. Kindly point > me > to what feature I need to read the docs about if it is... > > Thanks in advance. > > Regards > ~Rashmi > > > > -- "The greatest tyrannies are always perpetrated in the name of the noblest causes." Thomas Paine "Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety" - Benjamin Franklin
