Bob, Firs, thanks for your response.
Yes Bob, the approval is another task in the system and happens hours or days later. Yes I'm using cayenne. Stale Data ---------- I guess that the problem with stale data hasn't to do with roll backing, what happens is that after the commit, other navigator windows (other sessions) show old information. It looks like they are showing the view stored in their session objects. check-then-act -------------- What looks strange to me is that the check-then-act should be atomic once you submit, is a pattern in transactional systems, something like the transaction isolation level.. is like when in a multi-threaded environment you not only synchronize write access to fields, but reads too. I would like ------------- May be there is a way to manually create a transaction covering everything going on in the onPost() method, in this way the reads (check) and writes (act) would preserve the business rules, no matter how many windows or sessions could be trying to do it at once. Hans ----- "Bob Schellink" <[email protected]> escribió: > Hi Hans, > > [email protected] wrote: > > Hi, > > > > I have an strange behavior with transactions. > > > > I have a system where users must upload a document and then wait for > this to be aproved: > > > How long will the approval process take? Is this a manual task? > > > > The problem is that if i open "more than one document uploading > window" and press submit at once, eventually a race condition arise > and two documents get registered, breaking the business rule. > > > > Playing with the filter configuration in web.xml, i changed > session-scope to true. > > > > Magically this make the things work as expected and you can only > upload one document, and the race condition is eliminated. > > > I assume you are using Cayenne? > > What most likely happens with session-scope is that your transaction > blocks the second upload request at the session level. Once it commits > > the second request is processed. > > > > This solves the problem, but introduces another worst, sessions now > see stale data, each session has its own version of the instances. > > > The DataContextFilter has a "autoRollback" property (defaults to true) > > which automatically rolls back uncommitted changes in the DataContext. > > Have you set this to false perhaps? You should not see stale data if > you rollback uncommitted changes. > > > kind regards > > bob -- Hans Poo, WeLinux S.A. Oficina: 697.25.42, Celular: 09-319.93.05 Bombero Ossa # 1010, Santiago
