Could not commit JPA transaction: Transaction marked as rollbackOnly

前端 未结 5 1615
不知归路
不知归路 2020-11-30 21:45

I\'m using Spring and Hibernate in one of the applications that I\'m working on and I\'ve got a problem with handling of transactions.

I\'ve got a service class that

5条回答
  •  野性不改
    2020-11-30 22:33

    As explained @Yaroslav Stavnichiy if a service is marked as transactional spring tries to handle transaction itself. If any exception occurs then a rollback operation performed. If in your scenario ServiceUser.method() is not performing any transactional operation you can use @Transactional.TxType annotation. 'NEVER' option is used to manage that method outside transactional context.

    Transactional.TxType reference doc is here.

提交回复
热议问题