I have a Method in my Service, that is annotated with @Transactional
and @RollbackAlways
. I want to prevent any flushes during the execution of this method. I thought about just calling entityManager.setFlushMode(FlushModeType.COMMIT);
at the start of my method, but I don’t know if this will change the flushing behavior for the whole application or just for this single transaction.
I do not want to influence the flushing behavior of the whole application. I just want to prevent the flushing of any writing accesses to repositories that are performed in my rollbacked transaction.
Is there a solution for this exact problem?
Is there a good documentation that reliably explains what entityManager.setFlushMode(FlushModeType.COMMIT);
exactly does when called in a transaction?