For a CMP entity bean, specifies how primary keys are auto-generated. Primary keys can be auto-generated using Oracle or SQL server specific methods or a vendor-neutral named sequence table. A summary of the syntax is provided below. For detailed explanations and examples, see the related topics at the bottom of the page.
Class tag for a CMP entity bean.
@ejbgen:automatic-key-generation
type="keyGeneratorType"
[name="nameKeyGenerator"]
[cache-size="keyChacheSize"]
type
Required. The following key generator keywords are available:
- Oracle. Use an Oracle SEQUENCE database table.
- SQLServer. Use SQL Server's IDENTITY column.
- SQLServer2000. Use SQL Server 2000's IDENTITY column.
- NamedSequenceTable. Use a named sequence table.
Note. The SQLServer2000 option is the same as SQLServer, except that SQLServer uses @@IDENTITY column to get the generated key value and SQLServer2000 uses the SCOPE_IDENTITY() function instead.
cache-size
Optional. Specifies the size of the key cache.
name
Optional. Specifies the name of the Oracle SEQUENCE table or the name of the named sequence table.
The following rules apply to this tag's use:
When you specify the Oracle type, you must specify the name of the SEQUENCE table and the cache-size. The cache-size must match the value of the increment.
When you specify the NamedSequenceTable type, you must specify the name of the named sequence table and the cache-size. The cache-size determines how many keys are fetched from the named sequence table by the EJB container. A large cache size lowers the number of trips to the named sequence table.