struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Erickson" <derick...@cmcflex.com>
Subject Re: Strategy for out of date items through forms using hibernate?
Date Wed, 17 Dec 2003 20:50:35 GMT
> I have done this.  Hibernate supports versioning (using a version number
> column), if you use this Hibernate can make sure the changes are not
> overwritten.
>
> The basic process is:
> 1. Hibernate session A loads object A1 (with identifier 1234)
> 2. Hibernate session B loads object B1 (also with identifier 1234)
> 3. Session A modifies object A1 and saves it
> 4. B modifies object B1 and attempts to save it
> 5. Hibernate will detect the version number for the object has changed
> and generate an exception (StaleObjectStateException)
> 6. Catch this exception, close the hibernate session, return an error
> message to the user using ActionErrors etc
>
> I also have a refresh button so that at any time the user can press
> refresh which reloads the object from hibernate so it is up to date.
> When I return my stale object error I also allow the user to either
> refresh (loses the users changes), cancel (do nothing, return to parent
> menu), or overwrite.  Overwrite can attempt to overwrite the changes by
> reloading the new object, but use the posted field changes to update and
> then save the object.

Yes I figured this out just barely, rather I used timestamp instead of
version (are there any drawbacks to that?).  I am interested in doing
exactly what you did, but how did you go about overwriting the things that
have been changed?

Thanks,
David


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


Mime
View raw message