How to implement container managed transaction (CMT)?

后端 未结 3 906
余生分开走
余生分开走 2020-12-16 22:06

I wanted to persist an object(ReportBean) to the database, but I got error message:

javax.persistence.TransactionRequiredException: Transactio         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 22:46

    You are right, but in your solution you create a nested transaction, that runs insolated from the calling context. Unfortunately, i was not able to find a solution to pass a transctions context like this

    @Stateless
    public class ValidateReportAction extends ReportAction {
    ...
    
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public synchronized String createReport() {
    

提交回复
热议问题