I´ve been finding a solution for my issue of not working Spring Boot @Serializable
and @Transactional
on SO and I´ve found this solution
Everything works fine after removing @Synchronized
and adding @Transactional
with SERIALIZABLE
isolation level on top of my method which causes problem in race condition.
But when I try to run @SpringBootTest
I am getting error
Could not open JPA EntityManager for transaction; nested exception is org.postgresql.util.PSQLException: Cannot change transaction isolation level in the middle of a transaction.
I´ve tried to add a REQUIRES_NEW
propagation to force create a brand new transaction, but that did not work either.
The test is basically only calling a controller method using MockMvc
. Controller method just calls service method (on top of that method is that Transactional method) and the method simply reads data and if the data are present, update of this data is performed, otherwise the new entity is created.
And in the end I´d like to add that I am using PostgreSQL
database
Does anyone have a clue why this happens and how to possibly fix this issue?