8.2. Integrating with the Transaction Manager

Kodo EntityManagers and PersistenceManagers have the ability to automatically synchronize their transactions with an external transaction manager. Whether or not EntityManagers and PersistenceManagers from a given factory exhibit this behavior by default depends on the kodo.TransactionMode configuration property. The property can take the following values:

You can override the global transaction mode setting when you obtain an EntityManager using the KodoEntityManagerFactory's createEntityManager(PersistenceContextType ctype, boolean managed, int connRetainMode) method.

You can override the global transaction mode setting when you obtain a PersistenceManager using the KodoPersistenceManagerFactory's getPersistenceManager(boolean managed, int connRetainMode) method.

In order to use global transactions, Kodo must be able to access the application server's javax.transaction.TransactionManager . Kodo can automatically discover the transaction manager for most major application servers. Occasionally, however, you might have to point Kodo to the transaction manager for an unrecognized or non-standard application server setup. This is accomplished through the kodo.ManagedRuntime configuration property. This property describes a kodo.ee.ManagedRuntime implementation to use for transaction manager discovery. You can specify your own implementation, or use one of the built-ins:

See the Javadoc for of each class for details on the bean properties you can pass to these plugins in your configuration string.


This feature requires Kodo Enterprise Edition.

Example 8.3. Configuring Transaction Manager Integration

JPA XML format:

<property name="kodo.TransactionMode" value="managed"/>
<property name="kodo.ManagedRuntime" value="jndi(TransactionManagerName=java:/TransactionManager)"/>

JDO properties format:

kodo.TransactionMode: managed
kodo.ManagedRuntime: jndi(TransactionManagerName=java:/TransactionManager)

Note that even when Kodo is using managed transaction, you can control transactions through the specification local transaction APIs if you wish. Kodo will propagate your transaction calls to the global transaction.


Skip navigation bar   Back to Top