12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Container-Managed Persistence in <strong>Borland</strong> Enterprise Server<br />

UpdateModifiedFields<br />

VerifyModifiedFields<br />

Note<br />

This option is the default optimistic concurrency behavior. The container issues an<br />

update only on the fields that were modified in the transaction, or suppresses the<br />

update altogether if the bean was not modified. Consider the same bean from the<br />

previous example, and assume that only VALUE1 was modified in the transaction.<br />

Using UpdateModifiedFields, the container would issue the following update:<br />

UPDATE MyTable SET (VALUE1 = value1) WHERE KEY = key<br />

This option can provide a significant performance boost to your application. Very often<br />

data access is read-only. In such cases, not sending an update to the database upon<br />

every transaction saves quite a bit of processing time. Suppressing these updates also<br />

prevents your database implementation from logging them, also enhancing<br />

performance. The JDBC driver is also taxed far less, especially in large-scale EJB<br />

applications. Even for well-tuned drivers, the less work they have to perform, the better.<br />

This option, when enabled, orders the CMP engine to issue a tuned update while<br />

verifying that the updated fields are consistent with their previous values. If the value<br />

has changed in between the time the transaction originally read it and the time the<br />

transaction is ready to update, the transaction will roll back. (You will need to handle<br />

these rollbacks appropriately.) Otherwise, the transaction commits. Again using the<br />

same table, the CMP engine generates the following SQL using the<br />

VerifyModifiedFields behavior if only VALUE1 was updated:<br />

UPDATE MyTable SET (VALUE1 = value1) WHERE KEY = key AND VALUE1 = old-VALUE1<br />

VerifyAllFields<br />

This option is very similar to VerifyModifiedFields, except that all fields are verified.<br />

Again using the same table, the CMP engine generates the following SQL using this<br />

option:<br />

UPDATE MyTable SET (VALUE1 = value1) WHERE KEY = key AND VALUE1 = old-VALUE1<br />

AND VALUE2 = old-VALUE2<br />

The two verify settings can be used to replicate the SERIALIZABLE isolation level in the<br />

Container. Often your applications require serializable isolation semantics. However,<br />

asking the database to implement this can have a significant performance impact.<br />

Using the verify settings allows the CMP engine to implement optimistic concurrency<br />

using field-level locking. The smaller the granularity of the locking, the better the<br />

concurrency.<br />

Persistence Schema<br />

The <strong>Borland</strong> CMP 2.0 engine can create the underlying database schema based on<br />

the structure of your entity beans and the information provided in the entity bean<br />

deployment descriptors. You don't need to provide any CMP mapping information in<br />

such cases. Simply follow the instructions for “Specifying tables and datasources,”<br />

below. Or, the CMP engine can adapt to an existing underlying database schema.<br />

Doing so, however, requires you to provide information to the CMP engine about your<br />

database schema. In such cases, you should refer to the CMP mapping sections,<br />

below, as well as CASE 2 in “Specifying tables and datasources.” See “Basic Mapping<br />

of CMP fields to columns” on page 133.<br />

Specifying tables and datasources<br />

The minimum information required in ejb-borland.xml is an entity bean name and an<br />

associated datasource. A datasource is used to obtain connections to a database.<br />

Information on datasource configuration is given in Chapter 21, “Connecting to<br />

Resources with BES: using the Definitions Archive (DAR).” There are two means of<br />

providing this information.<br />

132 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!