MySQL auto-increment columns
FireStorm/DAO 2.0 now supports MySQL auto-increment columns. These columns are typically used to automatically provide unique values for a primary key.
Here is an example of a MySQL DDL script with an auto-increment primary key:
CREATE TABLE customer (
uid INT UNSIGNED NOT NULL AUTO_INCREMENT,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
PRIMARY KEY(uid)
);
Once you have generated DAO code using FireStorm, the programming model for using this table is as follows:
CustomerDao dao = CustomerDaoFactory.create();
Customer cust = new Customer();
cust.setUid( null );
cust.setFirstName( "Joe" );
cust.setLastName( "Bloggs" );
CustomerPk pk = dao.insert( cust );
System.out.println( "Created customer with ID = " + pk.getUid() );