+

Search Tips   |   Advanced Search

Sequence grouping for container-managed persistence in assembled EJB modules


Overview

After assembling an EJB module containing CMP beans, we can prevent certain types of database-related exceptions from occurring during application run time using sequence grouping, specifying 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

A database referential integrity (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 can cause an EJB application to violate RI rules, causing 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, in the EJB deployment descriptor editor of the assembly tool. We assign beans to CMP groups. Within each group, we specify the order in which the persistence manager inserts bean data into the database.

Sequence grouping can also reduce the risk of transaction rollback exceptions for entity beans configured for optimistic concurrency control, where 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 that these scenarios are less likely to occur.


Related concepts:

  • Enterprise beans
  • Concurrency control
  • Set the run time for CMP sequence groups
  • Container managed persistence bean associated technologies