I am confused about @Transactional annotation with base and subclasses. I have the following code with several generic subclasses derived from the base class CustomRepository<T> which implements ICustomRepository<T>. I want all the methods of the interface ICustomRepository<T> be transactional. Is it enough to put @Transactional just in the base class so that the call findAll() from sublasses also become transactional.
Tag: spring-transactions
Overriding transaction propagation levels for methods having Spring’s @transactional
I have multiple methods in my codebase annotated with Spring’s @transactional with different propgation levels (lets ignore the idea behind choosing the propagation levels). Example – Now I have a new use case where I want to perform all these operations in a single transaction (for this specific use case only, without modifying existing behavior), overriding any annotated propagation levels.
Data from test with @Transactional are persisting between tests
I have a small problem. I have started writing tests for my small project. The project uses SpringBoot, standard JpaRepository from Spring, as a testing framework I am using Spock and for testing the database, I’m using PostgreSQL container from TestContainers. The problem is, that data between tests is being persisted, despite the @Transacional on each of the tests. The
Not able to rollback DB changes in Aspect in Spring boot application
I have written one aspect around a service class. In the aspect, I am doing some operation in the before section, which I would like to be rolled back if some exception occurs in the enclosed service method. The service class is as follows: The aspect is as follows: I am seeing an exception in the service method is not
SpringBoot – @Transactional – not opening transaction
I am trying to use transaction in SpringBoot app , for some reason it just doesn’t work. Below is the code for the sample app. I have a rest api in MyRestController.java which invokes DBService.hello() method. In hello() method I insert a row into a table using JOOQ. I see transaction is NOT being created , after further debugging I
How to handle transactions with concurrent access in Spring
I have a service with one method: And I’m running Gatling with 2 parallel calls config with testModelId = 1L argument. As a result of these calls I’m getting error: What I can see from logs is that two calls have entered this method at once and each printed log I assumed that adding transaction annotation on this method would