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.

About this task

When you update data in your business logic, you will first be Finding data using an access bean, and then using the setters on the class to change data. At this point, the data is cached locally in the access bean. If you update values in the local cache of the access bean, you must also include a commitCopyHelper() call to update the database with the updated information. If you do not use the commitCopyHelper() method, any changes you make using setters on the access bean will not be persisted.

The following example shows how to retrieve, update, and commit data on the UserProfileAccessBean:


  1. Create a new access bean:
    UserProfileAccessBean abUserProfile = new UserProfileAccessBean();
  2. Set the primary key:
  3. Update the display name:
    abUserProfile.setDisplayName("My display name");
  4. Update the description for the user:
    abUserProfile.setDescription("My user description");
  5. Commit the changes: