mardi 9 mars 2021

Upgrading SpringBoot from 2.3.9 to 2.4.3 breaks my tests which uses soft delete (with @Where)

I had upgraded SpringBoot (2.3.9 to 2.4.3) on my project but my tests failed (8 of 2000). Theses tests are almost all concerning soft deleting like :

  var myobjectDatabase = getAMyobjectDatabase();
  myobjectDatabaseRepository.save(myobjectDatabase);

  // When
  myobjectDatabaseRepository.softDelete(myobjectDatabase);
  var myobjectRetrieved = myobjectDatabaseRepository.getById(myobject.getId());

  // Then
  assertThat(myobjectRetrieved).isNull(); // ERROR

So I had investigate and if I add entityManager.clear() between the softDelete and the getById, it works ! The same if I add @Transactional(propagation = Propagation.NOT_SUPPORTED).

But I don't like these "quickfix". I had read the changelogs but nothing about that.

Anyone can help me or change my mind ?

Thanks !

Aucun commentaire:

Enregistrer un commentaire