Help Primary Key generation

According to article "Generating Primary Key Values in CMP Beans" (http://www.netbeans.org/kb/41/generated-primary-keys.html) you can specifiy automatic primary key generation.

The following fragment describes a key issue when you have a existing database schema.

...

If the database schema is not created during deployment, the primary key column in the mapped table must be of type NUMERIC with a precision of 19 or more, and must not be mapped to any CMP field. The Sun Java System Application Server generates unique values for the primary key column at runtime.

...

In the used sample for how to set up a MySql database the creation of the customer table must be as follows:

CREATE TABLE customer (

id BIGINT(19) NOT NULL auto_increment, -- this column will be automat. generated

lastName varchar(25) NOT NULL,

firstName varchar(30) default NULL,

PRIMARY KEY (id));

My question is:

Is it nescesary to have the field id to be decleared auto incremented?

The first fragment says that the AS will create new values for the primary key. Or does the generation of primary keys only work if the pk field in the database table is auto incremented by the database?

Please help. Thanks!

Johan.

[1290 byte] By [kuifje] at [2007-11-26 7:24:16]
# 1

Hello Johan,

no, as i remember it does not work if you specify the id column as auto_increment. The J2EE bean container does manage the generation of the primary key, so the database must have a column type int(19) or bigint and primary key, not more.

Hope this helps, more information is in the J2EE documentation from Sun, page 1012.

Kind regards,

marc.

MJakob at 2007-7-6 19:10:32 > top of Java-index,Application & Integration Servers,Application Servers...
# 2
Tanks marc,If SJSAS is able to provide new PK values, I don't get why the database create sript (for customer) in the article has the primary key declared with auto-increment? Johan.
kuifje at 2007-7-6 19:10:32 > top of Java-index,Application & Integration Servers,Application Servers...
# 3
It's an error in the article :(-marina
marina at 2007-7-6 19:10:32 > top of Java-index,Application & Integration Servers,Application Servers...