我在一种方法(has @Transactional(propagation = Propagation.Required)
)中插入数据,但在另一种方法(has @Transactional(propagation = Propagation.Required)
)中,如果我尝试获取相同的数据,它会给出 null。
两种方法都写在服务层@Transactional (rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
如何获取插入到同一事务中的数据。就像是 :-
@Service
public class Service{
@Transactional
public void method(){
mapper.insert(); //insert to DB(Using Mapper interface)
ServiceLayer.method2()
}
}
@Service
public void ServiceLayer{
@Transactional
public static void method2(){
result = mapper.select() //Select inserted data - returning null
}
}