我在new
Spring事务中生成readonly
Spring事务。新事务正在DB中创建一个条目。在退出新事务后,我不能够获取readonly
事务中的数据,尽管此时已在数据库中创建了条目。
Interface A {
@Transactional(readOnly = true)
void methodA();
}
Interface B {
@Transactional(propagation = Propagation.REQUIRES_NEW)
void methodB();
}
Class classA implements A {
public void methodA() {
classB.methodB();
// select * from Employee where id = 1
// Problem: This returns nothing, maybe because it belongs to different transaction.
// >>>>>>>>>>> How can i access it here <<<<<<<<<<<<
}
}
Class classB implements B {
public void methodB() {
// Code to: insert into table Employee(id) values(1);
}
}