1
I have a method more or less like the following within a service:
@Transactional
public void atualizarPosicoes(Integer novaPosicao, Long idTarefaAtualizada){
this.repositorio.listAllTarefas().forEach((Tarefa tarefa) -> {
if(tarefa.getId().equals(idTarefaAtualizada)){
tarefa.setPosicao(novaPosicao);
}
});
}
See that in no time I execute one this.repositorio.save(tarefa) but at the end of the execution of my method my task in DB is updated. I tried to use the .stream() but the result is the same, in my specific case this is the expected behavior, but I was left with the doubt, because it persists even without me to execute the .save()?
Interesting, but are you sure you have not manipulated the object before? Did you update it before this method?
– nullptr
Yes, the method does just that, search for the repository and a set, but Lucas Miranda’s answer clarified.
– Victor Hartur de Carvalho