For us, several different approaches finally resolved the StaleObjectException exception:
object = object.refresh()
Updating objects after restoring them has allowed most of our StaleObjectExceptions. Especially in cases where it was possible that someone would work on the same object from another place and change some of its members (most problems were received with members of the collection).
Overall project stability:
wrongly linked resources
we had 404 in a specific resource file that we actually did not need, and therefore he ignored it for a while. it turns out that the missing file will cause the session to remain open - thus creating StaleObjects left and right.
Therefore, as a hint for anyone who encounters more than usual (some StaleObjects can always occur - see answers above) StaleObjectExceptions: make sure that all resources are connected correctly and your developer tools (Chrome F12) do not report any missing files.
Sebastian flückiger
source share