Managing connections and commitments

The Database Table Mapping service uses two attributes (autoConnect and autoCommit) to determine whether the service object handles the connection and commitment of changes to the tables as an atomic unit of work. The following table describes the behavior of the service object depending on the value of these attributes.
Table 1. Behavior of the service according to the autoConnect and autoCommit attributes
autoConnect autoCommit Service behavior
true true The service uses WebSphere(R) Application Server to create the connection and sets the databaseConnection attribute with the connection information. The application only needs to call the appropriate database access methods. Once the database access methods have finished, the service commits or rolls back the changes and then closes the connection.

The service definition must include the information needed to set the database connection automatically when the application requests access to the database.

false false The application must connect to the database, take care of committing and rolling back transactions, and explicitly close the connection.
false true The application must connect to the database and explicitly close the connection but the service automatically commits or rolls back changes to the database each time the application calls the database access methods.
true false The service uses WebSphere Application Server to create the connection and sets the databaseConnection attribute with the connection information. The application must commit and roll back all the changes made to the database through this connection. The application must then explicitly close the connection.

The service definition must include the information needed to set the database connection automatically when the application requests access to the database.

Note that this service works with existing database tables, so the application must set the primary key column value for any record to be inserted in the table, define this column as part of the JDBCTable service format definition, and add the name mapping between the data field that will contain this primary key and the table column into the service definition if this is needed.

To comply with the transaction support of WebSphere Application Server, in the application logic layer, the commitment of changes is automatic or does not affect the deployment description when you deploy the database services.

Table 2. Behavior of the deployed service in the application logic layer
autoCommit Valid Transaction Type Container Transaction Setting Rational
true Container NotSupported Separate local transactions
true Bean NotSupported No transaction
true Bean RequiresNew No transaction
false Container RequiresNew Separate global transactions

For more information, see the transaction support documentation for WebSphere Application Server.