everyone! I have a problem. I use Spring Data in my project with some microservices. One of them changes a row in DB. Then in my microservice I check that row. The main problem is that findById() method of Spring Data return old, not changed value. I put a breakpoin, my eyes see one value in DB, but repository give me another one. After some experiments I decided to try to write this query throught Spring JBDC. And now - everything is okay. This is Spring Data query:
Optional<MessageLog> byId = messageLogRepository.findById(id);
This is Spring JDBC:
public MessageLog findByIdJdbc(String id) {
SqlParameterSource sqlParameterSource = new MapSqlParameterSource("id", id);
String findByIdSQL = "SELECT * from MESSAGESLOG where ID = :id";
return namedParameterJdbcTemplate.queryForObject(findByIdSQL, sqlParameterSource, rowMapper);
}
Could you, please, give me an explanation or an article? I think that the problem can be in cache. But did not find an answer.