Flush remote method for entity beans

WebSphere Application Server does not write changes made on the entity beans to the database until the time the transaction is committed. As a result, the database may get temporarily out of synchronization with the data cached in the entity bean's container.

A flush remote method is provided (in the com.ibm.commerce.base.helpers.BaseJDBCHelper class) that writes all the committed changes made in the current transaction that is associated with the user request (it takes information from the enterprise bean cache) and updates the database. This remote method can be called by a command. Use this method only when absolutely required. It is expensive in terms of overhead resources and has a negative impact on performance.

Consider a logon command that includes the following code:


UserAccessBean uab = ...;
 uab.setRegisteredTimestamp(currentTimestamp);
 uab.commitCopyHelper();
Before the transaction is committed, the REGISTRATIONUPDATE in the USERS table is not updated with the current time stamp. The update only occurs when the transaction is committed. The flush method has to be used so that any direct JDBC query in the same transaction returns the user with the specified registration time stamp. For example, the following query finds all the users that registered after 2002-11-16 14:52:20:
select * from USERS where REGISTRATIONUPDATE > '2002-11-16 14:54:20'
The following sample code snippet shows how the flush remote method can be called by a command:

com.ibm.commerce.base.objects.ServerJDBCHelperAccessBean helper = new com.ibm.commerce.base.objects.ServerJDBCHelperAccessBean();
helper.flush();