I am trying to clear my doubts w.r.t. Spring Transaction boundaries with following example.
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void test() {
test1();
test2();
}
@Transactional(propagation=Propagation.NOT_SUPPORTED, readOnly=false)
public void test1() {
this.jdbcTemplate.execute("INSERT INTO TEST VALUES('T', 'C2', 0, 1)");
}
@Transactional(propagation=Propagation.SUPPORTS, isolation=Isolation.READ_UNCOMMITTED, readOnly=true)
public void test2() {
System.out.println(this.jdbcTemplate.queryForInt("select count(*) from TEST"));
}
I want to isolate test2() method from test1() that is each time test() is called test2() should not read the data committed by test1(). Please advice is it possible to handle this scenario using propagation or isolation attributes.
Thanks in advance.
See Question&Answers more detail:os