Spring data jpa @transactional

前端 未结 1 492
梦如初夏
梦如初夏 2020-12-05 11:45

Below is the flow of my application

Controller - services - repository

At the service layer we have @Transactional annotation We also have

相关标签:
1条回答
  • 2020-12-05 12:26

    See section 2.3 of the Spring Data Reference:

    http://docs.spring.io/spring-data/jpa/docs/1.0.0.M1/reference/html/#transactions

    CRUD methods on your repository are transactional by default. While these transactions can be configured as required, it is normally the case, as suggested in the comments above, that transactions be specified at the Service layer and in that case:

    The transaction configuration at the repositories will be neglected then as the outer transaction configuration determines the actual one used.

    So, in answer to your question, transactions can (and should be) specified at the service level regardless of any Spring Data transaction management.

    0 讨论(0)
提交回复
热议问题