【发布时间】:2011-04-04 12:12:40
【问题描述】:
我正在努力消除我的疑虑。 Spring 事务边界与以下示例。
@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"));
}
我想将 test2() 方法与 test1() 隔离,即每次调用 test() 时 test2() 不应读取 test1() 提交的数据。 请建议是否可以使用传播或隔离属性来处理这种情况。
提前致谢。
【问题讨论】: