http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getGeneratedKeys()
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, ….);