0
@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完成時它會被提交。交易不起作用。春季啓動@Transactional
即使使用spring.jpa.properties.org.hibernate.flushMode = MANUAL,Foo對象仍可立即顯示 – ropo