web server - Borland Technical Publications
web server - Borland Technical Publications web server - Borland Technical Publications
Implementing primary key generation by the CMP engine JDataStore JDBC3: using useGetGeneratedKeys Borland's JDataStore supports the new JDBC3 method java.sql.Statement.getGeneratedKeys(). This method is used to obtain primary key values from newly inserted rows. No additional coding is necessary, but note that this method is unsupported in other databases and is recommended for use only with Borland JDataStore. To use this method, set the boolean property useGetGeneratedKeys to True. Automatic primary key generation using named sequence tables Note A named sequence table is used to support auto primary key generation when the underlying database (such as Oracle SEQUENCE) and the JDBC driver (AUTOINCREMENT in JDBC 3.0) do not support key generation. The named sequence table allows you to specify a table that holds a key to use for primary key generation. The container uses this table to generate the keys. The table must contain a single row with a single column To use the name sequence table your table must have a single row with a single column that is an integer (for the sequence values). You must create a table with one column named “SEQUENCE” with any initial value. For example: CREATE TABLE TAB_A_SEQ (SEQUENCE int); INSERT into TAB_A_SEQ values (10); In this example key generation starts from value 10. To enable this feature, set it in in ejb-borland.xml: TABLE_A ID autoPkGenerator java.lang.String NAMEDSEQUENCETABLE namedSequenceTableName java.lang.String TAB_A_SEQ keyCacheSize java.lang.Integer 2 ...... Note that “ID” is the primary key column, which is marked for auto Pk Generation using NAMEDSEQUENCETABLE. The table used is TAB_A_SEQ. 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. Chapter 18: Generating Entity Bean Primary Keys 165
Implementing primary key generation by the CMP engine Note 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 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. There may be gaps in the keys generated if the container is rebooted or used in a clustered mode. 166 BES Developer’s Guide
- Page 125 and 126: Implementing an entity bean Generat
- Page 127 and 128: Container-Managed Persistence in Bo
- Page 129 and 130: Container-Managed Persistence in Bo
- Page 131 and 132: Setting Properties Setting Properti
- Page 133 and 134: Setting Properties into a BLOB. The
- Page 135 and 136: Setting Properties Automatic table
- Page 137 and 138: 126 BES Developer’s Guide
- Page 139 and 140: Container-managed persistence and R
- Page 141 and 142: Container-Managed Persistence in Bo
- Page 143 and 144: Container-Managed Persistence in Bo
- Page 145 and 146: Container-Managed Persistence in Bo
- Page 147 and 148: Container-Managed Persistence in Bo
- Page 149 and 150: Container-Managed Persistence in Bo
- Page 151 and 152: Container-Managed Persistence in Bo
- Page 153 and 154: 142 BES Developer’s Guide
- Page 155 and 156: Setting Properties J2EE 1.3 Entity
- Page 157 and 158: Setting Properties Figure 16.2 Edit
- Page 159 and 160: Setting Properties Table 16.1 ejb.m
- Page 161 and 162: Setting Properties Table 16.3 Table
- Page 163 and 164: Setting Properties Security Propert
- Page 165 and 166: Aggregate Functions in EJB-QL Selec
- Page 167 and 168: Support for ORDER BY Support for OR
- Page 169 and 170: Overriding SQL generated from EJB-Q
- Page 171 and 172: Container-managed data access suppo
- Page 173 and 174: 162 BES Developer’s Guide
- Page 175: Generating primary keys from a cust
- Page 179 and 180: Transaction manager services Consis
- Page 181 and 182: Transaction manager services When t
- Page 183 and 184: Transaction manager services Follow
- Page 185 and 186: Declarative transaction management
- Page 187 and 188: Declarative transaction management
- Page 189 and 190: JDBC API Modifications JDBC API Mod
- Page 191 and 192: Handling of EJB exceptions Applicat
- Page 193 and 194: 182 BES Developer’s Guide
- Page 195 and 196: Client View of an MDB Client View o
- Page 197 and 198: Clustering of MDBs This is yet anot
- Page 199 and 200: Error Recovery Redelivered messages
- Page 201 and 202: 190 BES Developer’s Guide
- Page 203 and 204: JNDI Definitions Module Important s
- Page 205 and 206: Disabling and Enabling a Deployed D
- Page 207 and 208: Configuring JDBC Datasources In the
- Page 209 and 210: Configuring JDBC Datasources To add
- Page 211 and 212: Defining the Connection Pool Proper
- Page 213 and 214: Defining the Connection Pool Proper
- Page 215 and 216: Descriptions of Borland Enterprise
- Page 217 and 218: Advanced Topics for Defining JDBC D
- Page 219 and 220: Connecting to JDBC Resources from J
- Page 221 and 222: Configuring JMS Connection Factorie
- Page 223 and 224: Defining Connection Pool Properties
- Page 225 and 226: Obtaining JMS Connection Factories
Implementing primary key generation by the CMP engine<br />
Note<br />
Key cache size<br />
When generating the primary key, the container fetches the key from the table in the<br />
database. You can improve performance by reducing trips to the database by<br />
specifying a key cache size. To use this feature, in the ejb-borland.xml file, you set the<br />
element to specify how many primary key values the database will<br />
fetch. The container will cache the number of keys used for primary key generation<br />
when the value of the cache size is > 1.<br />
The default value for key cache size, if not specified, is 1. Although key cache size is<br />
optional, it is recommended you specify a value > 1 to utilize performance optimization.<br />
There may be gaps in the keys generated if the container is rebooted or used in a<br />
clustered mode.<br />
166 BES Developer’s Guide