Hibernate StaleObjectStateException fix – Stack Overflow

I am fixing an StaleObjectStateException. We have multiple web applications accessing the same table in the database. Sometimes the exception occurs and we are capturing the exception but I want to find the appropriate solution to handle it by update and re-running the method. The line of code failing is using the “find” method from “getHibernateTemplate”. Even though it is selecting from the table, the auto flush is cause the exception to occur. I am looking at setting the flush mode to manual before calling the “find” method but it doesn’t seem like the correct solution and we want to avoid using pessimistic locking. Are there other ways to handle this exception ?