user manual

194 BES Developers Guide
Implementing primary key generation by the CMP engine
<property>
<prop-name>autoPkGenerator</prop-name>
<prop-type>java.lang.String</prop-type>
<prop-value>NAMEDSEQUENCETABLE</prop-value>
</property>
<property>
<prop-name>namedSequenceTableName</prop-name>
<prop-type>java.lang.String</prop-type>
<prop-value>TAB_A_SEQ</prop-value>
</property>
<property>
<prop-name>keyCacheSize</prop-name>
<prop-type>java.lang.Integer</prop-type>
<prop-value>2</prop-value>
</property>
</column-properties>
......
</table-properties>
Note that "ID" is the primary key column, which is marked for auto Pk
Generation using NAMEDSEQUENCETABLE. The table used is TAB_A_SEQ.
Note Set the ejb.CacheCreate property to false while using getPrimaryKeyAfterInsert
or useGetGeneratedKeys. The container needs to know the primary key to
dispatch calls to the bean instance. Therefore, it needs to know the primary
key at the same time the Create method returns.
Key cache size
When generating the primary key, the container fetches the key from the table
in the database. You can improve performance by reducing trips to the
database by specifying a key cache size. To use this feature, in the ejb-
borland.xml file, you set the <key-cache-size> element to specify how many
primary key values the database will fetch. The container will cache the
number of keys used for primary key generation when the value of the cache
size is > 1.
The default value for key cache size, if not specified, is 1. Although key cache
size is optional, it is recommended you specify a value > 1 to utilize
performance optimization.
Note There may be gaps in the keys generated if the container is rebooted or used
in a clustered mode.