Transaction management for multiple database Using Spring & Hibernate

后端 未结 3 1967
轻奢々
轻奢々 2020-12-16 05:57

Am coming up with a Spring & Hibernate application which has Inserts/Update to its own system database and it even has to Insert/update other systems with different data

3条回答
  •  我在风中等你
    2020-12-16 06:05

    This will need to be done by the container where your application runs (e.g. JBoss App Server) or you'll need to hook into some other transaction manager such as Bitronix. Out of the box in a JavaSE application, you'll only get a "best-effort" attempt at managing a transaction between multiple datasources.

    You'll need to define connections to both databases using an XA driver and then make sure your transaction manager is leveraging a two-phase commit.

    If you aren't familiar with Global transactions, start here: http://docs.spring.io/autorepo/docs/spring/4.2.x/spring-framework-reference/html/transaction.html#transaction-global

提交回复
热议问题