stalestateexception

Hibernate session not refreshing data from DB after initial commit failure

夙愿已清 提交于 2019-12-13 19:25:42
问题 I am working on a multithreaded Java application that uses Hibernate . We are getting a org.hibernate.StaleObjectStateException because we have optimistic locking in place and a certain entity (let's call it Pojo ) is updated from many application modules, which can and have collided in race conditions (I have not designed the application). The problematic code block looks something like this: Transaction txn = null; HibernateException ex = null for(int retryAttempt = 0; retryAttempt < 5;