Generating unique IDs

http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getGeneratedKeys()

http://stackoverflow.com/questions/1376218/is-ther-a-way-to-retrieve-the-autoincrement-id-from-a-prepared-statement

String sql = "INSERT INTO table (column1, column2) values(?, ?)";
stmt
= conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);


stmt
.executeUpdate();
if(returnLastInsertId) {
ResultSet rs = stmt.getGeneratedKeys();
rs
.next();
auto_id
= rs.getInt(1);
}

http://kccoder.com/mysql/uuid-vs-int-insert-performance/

==========================================================

SELECT @newuid := uuid();
INSERT INTO table (uuidfield, someotherfield) VALUES (@newuid, 'test');
INSERT INTO childtable ….. VALUES (@newuid, ….);