Mediator managed transactions
A JDBC connection is wrapped in a connection wrapper and passed to the Data Mediator Service (DMS) during the instance creation. The ConnectionWrapper object contains the connection that is used by the JDBC DMS and indicates whether the mediator manages the current transaction. When the JDBC DMS manages the transaction, it performs commit and rollback operations as required. However, the DMS does not perform any transaction management activities if the wrapped connection is currently engaged in another transaction.The default action is to manage transactions.
Non-mediator managed transactions
When a passive connection wrapper is passed to the DMS, the DMS takes no managerial action; a passive wrapper is generally intended for an existing transaction that is under external management. Commit or rollback operations are not performed by the connection wrapper in this case.Protection against referential integrity (RI) violations
The JDBC Data Mediator Service safeguards data transactions from incurring RI violations and other database logic violations. When the JDBC DMS applies the updates of a data graph to a back end, it automatically orders the change operations so that they do not violate database RI policy. Similarly, the DMS filters counter operations (such as INSERT and DELETE) so that opposing client requests can perform updates in a logical order. The client deletes one object, and then creates an entirely separate object with the same primary key. The DMS transforms these two operations into an update operation that modifies the existing database object.Optimistic concurrency control collision monitoring
To diagnose transaction problems that are caused by update collisions, implement an optimistic concurrency control (OCC) strategy for the JDBC DMS.An update collision occurs when client data that populates a data graph is changed in the database before the data graph can submit the modifications of the client. If you configure the JDBC DMS for OCC, the DMS issues an OCC-specific exception when such a data collision happens. The OCC exception contains collision details such as the original row values, current row values, and the attempted row values. The client application uses these values to determine how to recover from the collision. For example, the application can reread the data and restart the transaction.
Be aware, however, that when one exception occurs, there is no way of knowing whether more exceptions exist deeper in the data graph schema and therefore are not displayed.
To activate OCC for the data mediator service, you must incorporate OCC columns into your database tables.
Setting the OCC Column
Column collisionColumn = table.addIntegerColumn("OCC_COUNT"); collisionColumn.setNullable(false); table.setCollisionColumn(collisionColumn);These lines accomplish the following:
For a full-fledged code example that forces a collision to demonstrate the OCC exception, see the topic Example: OCC data collisions and JDBC mediator.