I have spring data configured for my application where my DAO interface extends org.springframework.data.repository.CrudRepository to performer simple database operations. One of the DAO's findOne(id) method is not returning the latest record of a table even though my database has the latest data. It is always returning the old version of the record. There is no caching configured for the application. Is there any default JPA level caching which is preventing it to return the latest data?
EDIT: I am calling em.flush() after saving the record, so the subsequent call to findOne(id) must give me the latest record.
However, I see the one potential issue, my entire application is running in a clustered environment, so calling em.flush() might be refreshing the data only in one node where the data is being updated and all other nodes might still have the old data which may be causing the subsequent call to findOne(id) method is going through some other node where flush may not have happened yet. Is there a way to flush across nodes or is there any default timeout where the data gets refreshed automatically?