Bean – related Concept in WCS

In WebSphere Commerce Server as a developer we need to know how the data of retrieving and updating is happened using the business logic, for achieving this implementation we will be interacting with the entity beans with the help of access beans instead of directly calling the Entity beans. As we know Access beans are the java bean classes that hide the enterprise bean specific programmatic interfaces visibility from the client.

Types of methods present in the Access beans to access the DB are mentioned below:

  1. refreshCopyHelper();
  2. commitCopyHelper();

now let’s discuss a bit regarding the above methods like they are being called up and why for this methods are used in WCS,

  • refreshCopyHelper(): this method will be treated as ‘find for an update’ and its also used to lock that  particular table unless or until we are done with accessing of that table data for the entire transaction related to that data. While using the accessing of Db using this method will give the developer to check the data and implement n no of changes to the data, once done the job finally the release on the DB is released.
  • commitCopyHelper(); this method is mainly used to change the state of the access bean by updating the data present in the DB by inserting the new values into the required fields of the table in WCS. This updating of data is happened through the method called upon in the related access bean.
Create a new access bean :
UserProfileAccessBean abUserProf = new UserProfileAccessBean ();
Set primary key:
abUserProf.setInitKey_UserId(getUserId().toString());
Update the display name:
abUserProf.setDisplayName("My display name");
Update description for user:
abUserProfile.setDescription("Description");
Commit the changes:
abUserProfile.commitCopyHelper();

the above code snippet is a sample part of initialization of accessbean and updating the fields of the DB related to the corresponding Table in DB.

reference : IBM – Wcs infocenter

Leave a Reply