@Component
public class MyComponent {
@Autowired
private MyService myService;
@Transactional
public boolean processStream(InputStream is) {
...
myService.doIt(foo);
...
}
}
@Service
public class MyServiceImpl implements MyService {
@PersistenceContext
private EntityManager em;
@Transactional
public Lei doIt(Foo foo) {
...
foo = em.merge(foo);
...
}
}
我的问题是,在处理流时,Foo对象已经提交到数据库。我希望在processStream完成时提交它。
答案 0 :(得分:0)
得到它:MyComponent :: processStream()是从MyComponent :: processFile()调用的
似乎在ENTRY METHOD
上需要@Transactional注释这有助于调试: logging.level.org.springframework.transaction.interceptor = TRACE