WAS v8.5 > Develop applications > Develop EJB applications > Assemble EJB 2.1 enterprise beans

Sequence grouping for container-managed persistence in assembled EJB modules

After assembling an EJB module containing container-managed persistence beans, we can prevent certain types of database-related exceptions from occurring during application run time. Using sequence grouping, we can specify the order in which entity beans update relational database tables.

Entity beans are not supported in EJB 3.x modules.


Eliminate exceptions resulting from referential integrity (RI) violations

Sequence grouping is particularly useful for preventing violations of database referential integrity (RI). A database RI policy prescribes rules for how data is written to and deleted from the database tables to maintain relational consistency. Run-time requirements for managing bean persistence, however, can cause an EJB application to violate RI rules, which can cause database exceptions. These runtime requirements mandate that:

Consequently, the order in which entity beans update the database is unpredictable. That randomness translates into high risk of the application violating database RI. Although caching the operations for batch processing overrides these runtime requirements, it does not guarantee a bean persistence sequence that follows any given RI policy.

The only way to guarantee a persistence sequence that honors database RI is to designate the sequence, which we do in the EJB deployment descriptor editor of the assembly tool. Through the sequence grouping feature, you assign beans to CMP groups. Within each group, we specify the order in which the persistence manager inserts bean data into the database to accomplish updates without violating RI.

See the Set the run time for CMP sequence groups topic for detailed instructions on designating sequence groups. Consult the database administrator about the RI policy with which you need to synchronize.


Minimize exception risk for optimistic concurrency control schemes

Sequence grouping can also reduce the risk of transaction rollback exceptions for entity beans configured for optimistic concurrency control. In these concurrency control schemes, database locks are held for minimal amounts of time so that a maximum number of transactions consistently have access to the data. The relatively unrestricted state of the database can lead to transaction rollback exceptions for two common reasons:

Use the sequence grouping feature to order bean persistence so these scenarios are less likely to occur.


Related concepts:

Enterprise beans
Concurrency control


Related


Set the run time for CMP sequence groups


Reference:

Container managed persistence bean associated technologies


+

Search Tips   |   Advanced Search