On Wed, May 12, 2010 at 10:52 AM, David Sheth <[email protected]> wrote: > Hi all. I'm new to wicket. I was reading in the Wicket In Action book on > LoadableDetachedModels...particularly how when the model is detached, just > the id of the actual database persistent object is stored. Then, in the > load method, you retrieve the persistent object from the database. That all > makes sense. > > However, I then read one use case for this, at > http://stronglytypedblog.blogspot.com/2009/03/wicket-patterns-and-pitfalls-1.html. > The idea is that you retrieve the object from the database to present > in > a form, and then when a person submits the form, you retrieve the object > from the database again, apply any needed changes, and then persist the > object. > > Isn't there a problem here related to versioning of objects? Specifically, > the first time I retrieve an object, it could be at version 1. The next > time I retrieve the object, to apply the values from the form, I could be > retrieving version 4. I would then apply the changes from the form, and > hibernate would happily persist the object, because version 4 is the most > current.
Yes, Hibernate's automatic optimistic locking fails in this scenario. You can add your own validator onto the form (with a hidden field for the version) if you want. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
