We call a method (method1) with annotation @Transactional; inside the method1 we call another method (method2) with annotation @Transactional(propagation = Propagation.REQUIRES_NEW).
In the method2 we have one insert and one update in table.
When exiting from method1 the same update and insert in table occur causing a data integrity violation.
How can we make the changes made in method2 visible to method1 so that the second insert/update does not occour? Thanks in advance
This depends on the transaction isolation level that you used. Using SNAPSHOT isolation (also known as repeatable read) will not work. You have to configure the READ COMMITTED isolation level. Since you start the first transaction with method1 before the second in method2, the first transaction would never see anything that happens after it started when using SNAPSHOT isolation.