To use container-managed entity managers, configure JTA data sources in the persistence.xml
file. JTA data sources are managed data sources and are associated with JTA transactions.
SAP Business Technology Platform, Neo environment will sunset on December 31, 2028, subject to terms of customer or partner contracts.
For more information, see SAP Note 3351844.
This documentation refers to SAP Business Technology Platform, Neo environment. If you are looking for documentation about other environments, see SAP Business Technology Platform
↗️ .
To configure JTA data sources, set the transaction type attribute (transaction-type
) to JTA and specify the names of the JTA data sources (jta-data-source
), unless the application is using the default data source.
-
In the Project Explorer view, select
<project>/Java Resources/src/META-INF/persistence.xml
, and from the context menu choose Open With > Persistence XML Editor. -
On the Connection tab, enter the transaction type
JTA
or leave the default setting, which is JTA. -
If the application is using an explicitly named data source, enter the JNDI name of the data source in the JTA data source field.
If it uses the default data source, you don't need to specify a data source in the
persistence.xml
file. -
If the application uses more than one data source, define a corresponding number of persistence units, each with its own data source. The data source name is the JNDI name used for the lookup and must match the name used for the schema binding. To do this, switch to the Source tab of the
persistence.xml
file.The example below shows the persistence units defined for two data sources, where each data source is associated with a different database:
<persistence> <persistence-unit name="hanadb" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>jdbc/hanaDB</jta-data-source> <class>com.sap.cloud.sample.persistence.Person</class> <properties> <property name="eclipselink.ddl-generation" value="create-tables" /> </properties> </persistence-unit> <persistence-unit name="maxdb" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>jdbc/maxDB</jta-data-source> <class>com.sap.cloud.sample.persistence.Person</class> <properties> <property name="eclipselink.ddl-generation" value="create-tables" /> </properties> </persistence-unit> </persistence>
-
Save the file.
Related Information