Develop > Persistent object model
WebSphere Commerce enterprise beans
The persistence layer within the WebSphere Commerce architecture is implemented according to the EJB component architecture. The EJB architecture defines two types of enterprise beans: entity beans and session beans. Entity beans are further divided into container-managed persistence (CMP) beans and bean-managed persistence (BMP) beans.
Most of the WebSphere Commerce entity beans are CMP entity beans. A small number of stateless session beans are used to handle intensive database operations, such as performing a sum of all the rows in a particular column. One advantage of using CMP entity beans is that developers can utilize the EJB tools provided in WebSphere Commerce Developer. These tools allow developers to define Java objects and their database table mappings. The tools automatically generate the required persisters for the entity beans. Persisters are Java objects that persist Java fields to the database and populate Java fields with data from the database.
WebSphere Commerce uses EJB 2.x modules, but most of the entity beans are at EJB 1.1 level. WebSphere Commerce Developer provides two extensions to the EJB 1.1 specification: EJB inheritance and association. EJB inheritance allows an enterprise bean to inherit properties, methods, and method-level control descriptor attributes from another enterprise bean that resides in the same group. An association is a relationship that exists between two CMP entity beans.
Some of the WebSphere Commerce entity beans exploit the EJB inheritance feature. The WebSphere Commerce entity beans do not use the associations feature. To minimize complexity in the object model it is recommended that you do not use the association feature when developing entity beans. Instead of using associations, use object relationship between enterprise beans. Do this by adding explicit getter methods in the enterprise beans.
WebSphere Commerce provides two sets of enterprise beans: private and public. Private enterprise beans are used by the WebSphere Commerce runtime environment and tools. You must not use or modify these beans.
Public enterprise beans, on the other hand, are used by commerce applications, and can be both used and extended. These public enterprise beans are organized into the following EJB modules:
- Catalog-ProductManagementData
- ContentManagement-WorkspaceFlowData
- Enablement-BaseComponentsData
- Enablement-RelationshipManagementData
- Enablement-TicklerData
- GiftRegistry-BaseComponentsData
- GiftRegistry-OrderIntegrationData
- Marketing-CampaignsAndScenarioMarketingData
- Marketing-CustomerProfilingAndSegmentationData
- Marketing-ExperimentationManagementData
- Member-MemberManagementData
- Merchandising-PromotionsAndDiscountsData
- Order-OrderCaptureData
- Order-OrderManagementData
- WebSphereCommerceServerExtensionsData
- Trading-AuctionsAndRFQsData
Some of the EJB modules in the preceding list contain session beans. In order to simplify migration in the future, you should not modify a session bean class. If required, you can create a new session bean in the WebSphereCommerceServerExtensionsData EJB module. For more information about creating new session beans, refer to Write new session beans.
A program that uses enterprise beans must deal with the Java Naming and Directory Interface (JNDI) as well as the home and remote interfaces of enterprise beans.
To simplify the programming model, an access bean for each enterprise bean is generated. When creating the own enterprise beans, use the tooling in WebSphere Commerce Developer to generate this access bean.
- Object life cycles
The enterprise beans in the object model include both independent and dependent objects. An independent object has its own life cycle, controlled directly by the create or remove requests of the business logic invoking the object. A dependent object has a life cycle that is attached to another object, known as the owner object (which may also in turn be a dependent object, but further up the association hierarchy, an independent object exists). When the owner object is deleted, all dependent objects are also deleted. The actual deletes are controlled by cascading delete specifications within the database.
- Transactions
The Enterprise JavaBeans v2.1 architecture specifies three alternative commit-time options with respect to the instance state.
- Primary keys
A primary key is a unique key that is part of the definition of a table. It can be used to distinguish one record from others. All records must have a primary key. When you create a new record in a table, you may need to generate a unique primary key for the record.
- Access beans
WebSphere Commerce commands interact with access beans rather than directly with entity beans. Access beans provide a simpler interface to clients, caching of the home object, and reduced call traffic to the enterprise bean.
- Extend the WebSphere Commerce object model
Application requirements may lead you to extend the existing WebSphere Commerce object model. The WebSphere Commerce object model can be extended in two ways.
Related concepts
Extend the WebSphere Commerce object model
Related tasks