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.Access beans behave like Java beans, and hide all enterprise bean-specific programming interfaces from the client, like the JNDI, home and remote interfaces. Using access beans has additional advantages:
- At run time the access bean caches the enterprise bean home object because look ups to the home object are expensive, in terms of time and resource usage.
- The access bean implements a copyHelper object that reduces the number of calls to the enterprise bean when commands get and set enterprise bean attributes. Only a single call to the enterprise bean is required when reading or writing multiple enterprise bean attributes.
On the access bean, the get and set methods are not automatically cached. Only the methods that are part of the copy helper object are cached. The getters and setters on the remote interface are invoked when called.
In most cases, a program that uses enterprise beans must deal with the 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 your own enterprise beans, use WebSphere Commerce Developer to generate this access bean.
The following diagram displays the interaction between commands, access beans, entity beans, and the database.
Finding data using an access bean
You will be using access beans in your business logic when you want to find data in the WebSphere Commerce database. Within an access bean, select the appropriate database record by using the primary key, or a finder method.Updating data using an access bean
You can update data in your business logic by using an access bean to retrieve and change data. The commitCopyHelper() method is used to commit the changes you make in the access bean to the WebSphere Commerce database.Inserting data using access beans
You can access beans to create new data as part of your business logic.Deleting data using an access bean
You can delete data from the WebSphere Commerce database in your business logic using the remove() method on the access bean's EJB remote interface.Related concepts
Finding data using an access bean
Updating data using an access bean