Suppose you have an object on which you can cast a vote, this object maintains it's own vote count
In normal java one would synchronize the addVote method to ensure you don't lose votes Obviously this would be pointless in hibernate where objects are transaction scoped.
Pessimistic locking won't scale, so I guess you'd have to use optimistic locking, however when someone presses a cast vote button, you can't really serve them a stale data error please vote again dialog if the locking failed
I and I am kind of hessitant to just retry load -> add -> save untill it doesn't throw an exception, because if you don't make some elaborate max retry system, potentially it could bring the entire system down, would this really be the best option ?
|