All of the data sources are declared as JNDI resources at the Tomcat level. They are declared as Bitronix data sources managed by BitronixTransactionManager. At the Spring context level, all data access is wrapped by JPA using the Hibernate 4.x Framework. BitronixTransactionManager is auto fetched and injected by Spring as its JTA manager to manage all JPA services for any of the data sources. The following figure shows the JTA and JPA setup with multiple data sources:
The persistence.xml
file contains five persistence units wherein each is configured to fetch its XA-based data source through the JTA transaction manager. Each persistence unit must know that they are all JNDI data sources managed by the Bitronix transaction manager.
Each persistence unit is mapped to their respective EntityManagerFactory, JPA vendor adapter, and JNDI mappings. For more details on JTA-managed data sources, Chapter 7, Online Cart System (OCS), has all the codes...