I have a Test like this:
@Transactional
@Test
public void addRemoveTest() {
MyEntitiy entity = new MyEntitiy ();
entity = textureRepository.saveAndFlush(entity );
TestTransaction.flagForCommit();
TestTransaction.end();
TestTransaction.start();
final MyEntitiy loadedTexture = myEntityRepository.findOne(entity .getId());
}
This works perfectly fine. But when I remove the Committing code for the transaction, the repository will not call the database when calling findOne()
. Can I somehow force it to make the database call for my tests?
I prefer my test to not commit any transaction.
I'm not able to get the Session
to clear the cache. And I'm not even sure if clearing the session would help.