A common scenario I run into is having a web application where the user needs to edit 
a database record.

The simplest approach I can find is this -
1.) Load the db record into a bean. Copy the bean props. to the form for display. Put 
the dbbean in the session. 

2.) Show the form, when the user presses "save", validate the form, make sure, if 
possible, that the form primary key fields are equal to the dbbean in the session 
primary fields. 

3.) Have the dbbean do an update statement. In order to do this properly, the dbbean 
needs to have kept the original db values so they can be put in a where clause. This 
insures that we are changing the record exactly as we loaded it. If somone made a 
change before the page was submitted, the update would fail.

Is that the best approach to accomodate a sort of "optomistic locking"? Are there any 
tools to autogenerate the dbbean objects? I was thinking of trying to do it with an 
xml schema and XSLT to transform the schema to java objects. Thoughts? 

Thanks,
Ryan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to