CMP/JBoss: The Definitive GuideBy Jeremy BoynesCMP FieldsCMP Fields are the basic unit of information for CMP Entity beans, and this section covers declaration, coding and serialization issues. Dependent Value ClassesThe EJB specification states that the type of a cmp-field must either be a primitive or a Serializable class. Dependent Value Classes provide a mechanism for mapping more complex Java types onto individual database columns avoiding the need to serialize values into the database. Container Managed RelationshipsContainer Managed Relationships (CMR) allow a developer to define relationships between entities that are automatically managed by the CMP implementation. This can be used to simply represent the business data model in the Entity layer and allow applications to easily navigate between entities. Further, by defining the relationships in a manner the EJB Container can understand, it can factor them into the requests it makes to the store, potentially reducing the number of operations needed and significantly improving performance. Mapping CMRs to SQL DatabasesThis article describes the mechanisms used by JBoss CMP to map Container Managed Relationships (CMR) defined in the EJB tier to relational databases using SQL. Finder and ejbSelect MethodsFinder and ejbSelect methods provide a mechanism for locating entities in a persistent store without having to write code to access it natively. The methods allow the programmer to execute the queries; the definition of the query and how it is mapped to the store is defined in the deployment descriptor. EJB Query LanguageEJB-QL is a language for writing the queries that CMP must execute for Finder and ejbSelect. It is similar to the SQL language used for relational databases, but just different enough that subtle differences can lead to confusion. EJB-QL is intended to describe queries operating on a collection of Objects and not on the simple table/row/column structure people are typically familiar with. It is similar to SQL, but is closer to the Object-Relational model of SQL-99 than to traditional SQL-92. Primary KeysPrimary keys define the identity of a CMP Entity Bean, allowing to be found and operated on. Selecting the right primary key is critical for efficient operation of the CMP engine. Key GeneratorsJBoss CMP supports the use of key generators to automatically provide values for EJBs that have an Unknown Primary Key. This article describes the configuration of these key generators. CMP Managed Audit FieldsCMP has the ability to automatically update certain columns in the database when create or update operations are performed. These can be used to implement a basic auditing strategy. Locking MechanismsJBossCMP works in conjunction with the Entity locking mechanisms in JBoss to control access to CMP Entities and avoid potentially inconsistent modifications to data. Unlike BMP, the application code does not need to participate in the locking strategies. Tuning CMP PerformanceTuning of JBoss CMP is a finicky and error prone process. This article walks you through the ins and outs of the JBoss CMP tuning options. JBossCMP Mappings to Physical DatabasesNot all databases are created equal. Although the JDBC API provides mechanisms that hide the different physical characteristics of different database systems, there are some issues that it does not address which require JBossCMP to be configured for each platform. |
|
|||||
© 2003 Core Developers Network Ltd "Core Developers Network", the stylized apple logo and "Core Associates" are trademarks of Core Developers Network Ltd. All other trademarks are held by their respective owners. Core Developers Network Ltd is not affiliated with any of the respective trademark owners. |