+

Search Tips   |   Advanced Search

Configure two resource reference files on the same data source

We can configure two resource reference files on the same data source. This allows us to extend the custom properties for the data source to be extended to include two different schema names (currentSQLId on z/OS or currentSchema name in the custom properties) used to exploit the capabilities of the application server.

To use this feature, the application must be configured to use JPA 2.0 specifications.. When an EntityManager is created, the application server obtains a connection to the database. When using a pessimistic transaction, the EntityManager will retain that connection until the EntityManager is closed. When there are two EntityManagers that extend the data source definitions, the openjpa.jdbc.TransactionIsolation property might cause a problem with the transaction. This property can be found in the persistence.xml file in the following entry:

property name="openjpa.jdbc.TransactionIsolation" value="read-committed" 
In order to satisfy this request, Java Persistence API (JPA) will obtain a connection and immediately call setTransactionIsolation(READ_COMMITTED). When we have two EntityManagers share a single physical connection to the database, the first EntityManager creates a connection to the database and involves that connection in a transaction. When the second EntityManager creates a connection, it is not able to change the isolation level.

We can avoid this problem by creating two resource reference files in the same data source. Create the resource references with Rational Application Developer or by editing the XML files. You will need to make changes to the ejb-jar.xml, ibm-ejb-jar-bnd.xml, ibm-ejb-jar-ext.xml, persistence.xml files.

For IBM Optimâ„¢ PureQuery Runtime, if this is an XA data source we must define a new custom property on the data source where property_name = downgradeHoldCursorsUnderXa and boolean value = true. See the following sections for information on how to accomplish this:


Tasks

  • Extend DB2 data source definitions at the application level