Chapter 8 Creating J2EE Applications for BEA WebLogic


Flushing the CMP Cache

The EJB 2.0 specification requires that updates made by a transaction be reflected in the results of queries, finders, and ejbSelects issued during the transactions. As this requirement can slow performance, a new option has been added that allows you to specify that the cache be flushed before the query for the bean is executed.

If this option is turned off, which is the default behavior, you will not see the changes as a result of the query. If this option is turned on, the container will flush all changes made by the current transaction to disk before executing the query and the will appear in the results.

To enable this option set the include-updates element to true in weblogic-cmp-rdbms-jar.xml file. An example of this code follows:

<weblogic-query>
	<query-method>
	<method-name>findBigAccounts</method_name>
	<method-params>
		<method-param>double</method-param>
	</method-params>
	</query-method>
	<weblogic-ql>WHERE BALANCE>10000 ORDERBY
		NAME</weblogic-ql>
	<include-updates>true</include-updates>
</weblogic-query>

The default is false, which provides the best performance. When this element is set to false, it specifies that updates made to the current transaction must be reflected in the result of a query. This means that you will not see the changes as a result of the query.

When deciding to use this feature, you will need to determine when performance is more important that having consistent data.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.