Chapter 8 Creating J2EE Applications for BEA WebLogic


Automatic Primary Key Generation

WebLogic Server supports an automatic primary key generation feature for container-managed-persistence (CMP). Generated key support is provided in two ways:

CREATE table_name (SEQUENCE int)
INSERT into table_name VALUES (0)

In the weblogic-cmp-rdbms-jar.xml file, set the key_cache_size element to specify how many primary key values a database SELECT and UPDATE will fetch at one time. The default value of key_cache_size is 1. We recommend that you set this element to a value of >1, to minimize database accesses and to improve performance.

At this time, WebLogic Server only provides DBMS primary key generation support for Oracle and Microsoft SQL Server. However, named/sequence tables can be used with other unsupported databases. This feature is intended for use with simple (non-compound) primary keys.

Note: This feature is supported for the CMP 2.0 container only, there is no automatic primary key generation support for CMP 1.1. For 1.1 beans, you must use Bean-Managed-Persistence (BMP.)

Note: The key field must be declared to be of type java.lang.Integer in the abstract `get' and `set' methods of the bean.

 


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