Including an attribute in a predicate for optimistic access intents

For attributes of EJB 2.x CMP entity beans, the Properties view of the Mapping editor includes a property for optimistic predicate.

If you have an optimistic access intent setup (wsOptimisticUpdate or wsOptimisticRead), you need to specify the attributes that you want to be included in the predicate. If an attribute is set to true, the attribute will be included in the WHERE predicate in the bean's UPDATE SQL statement. By default, the mapping editor sets each attribute to false, except for attributes that are primitive types, which are set to true.

  1. Open the mapping editor for your EJB application.
  2. In the Overview section of the Mapping editor, select the bean attribute that you want to include in a predicate for optimistic access intent.
  3. In the Properties view, set the OptimisticPredicate value to true.
Note:
  • In versions of WebSphere® Studio Application Developer earlier than V5.0, adding attributes of an EJB 1.1 CMP entity bean to an optimistic predicate was not supported. However, if you use the workbench to deploy an EJB application that you developed using a version earlier than V5.0 and does not include a list of attributes for an optimistic predicate, all of the available predicates are used. EJB 2.x CMP entity beans are treated differently. If no attributes are selected as predicates, then none are added to the overqualified update.

  • In versions of WebSphere Application Server Toolkit earlier than v6.0.1 (or IBM Rational Software Development Platform earlier than v6.0.0.1), the attributes that are included in an optimistic predicate mapped to nullable columns was not supported. However, for this version of the product and higher, this restriction has been relaxed:
    For DB2 Universal Database for z/OS and OS/390, V8 and higher, if the optimistic predicate column is nullable, the resulting UPDATE query uses the "IS NOT DISTINCT FROM" construct. For example, if ID is the primary key column and NAME is nullable, then the resulting UPDATE query is:
    UPDATE SET NAME = ? WHERE ID = ? AND NAME IS NOT DISTINCT FROM ?
    This new IS NOT DISTINCT FROM syntax removes the restriction against null predicates on DB2 Universal Database for z/OS and OS/390, V8 and higher for both JDBC and SQLJ.

    For all other backends database vendors, beans with nullable predicate columns can be used by enabling partial update for that bean (selecting the UPDATE_ONLY value for the partial operation). Partial update is supported for JDBC only. For SQLJ, the restriction against null predicates remains. For more details on using partial operation as a persistence option, refer to the following two topics: Partial operation for container managed persistence and Adding bean-level access intent for entity beans 2.x.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.