What transaction manager to use? (JPA, Spring)

前端 未结 3 503
有刺的猬
有刺的猬 2020-12-29 05:44

I\'m developing a web application based on JPA + Hibernate, Spring and Wicket. I was wondering what\'s the best way of implementing transactions in my code? What transaction

相关标签:
3条回答
  • 2020-12-29 05:49
    org.springframework.orm.jpa.JpaTransactionManager
    

    My preference is to use this with annotation:

    <tx:annotation-driven transaction-manager="myTxManager" />
    
    0 讨论(0)
  • 2020-12-29 05:52

    The org.springframework.transaction.PlatformTransactionManager interface is the key abstraction in the Spring API providing essential methods for controlling transaction operations at run-time: begin, commit and rollback.

    PlatformTransactionManager interface, its implementations

    1. JtaTransactionManager -----> JTA
    2. DataSourceTransactionManager -----> JDBC
    3. JpaTransactionManager ------> JPA
    4. HibernateTransactionManager ------> Hibernate

    it depand on your requirment which moudle of spring your are using

    0 讨论(0)
  • 2020-12-29 06:10

    nanda is right, you can only use JpaTransactionManager. The Transaction Manager abstraction we are talking about here is Spring's PlatformTransactionManager interface, and JPATransactionManager is the only implementation of that interface that understands JPA.

    You should read the chapter Transaction Management from the Spring reference to better understand this topic.

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