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.

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, 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

//Create a new access bean
UserProfileAccessBean abUserProfile = new UserProfileAccessBean();

//Set the primary key
abUserProfile.setInitKey_UserId(getUserId().toString());

//Update the display name
abUserProfile.setDisplayName("My display name");

//Update the description for the user
abUserProfile.setDescription("My user description");

//Commit the changes
abUserProfile.commitCopyHelper();

Related concepts

Access beans

Finding data using an access bean

Inserting data using access beans

Deleting data using an access bean