mysql: Fix sequence generators
Some versions of MySQL database server and/or the JDBC driver
refuse to return the auto increment primary key column of the last
INSERT statement unless we specifically ask for it when we execute
the statement.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java b/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java
index 6b96faf..0fa42cf 100644
--- a/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java
+++ b/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java
@@ -80,7 +80,8 @@
try {
final Statement st = conn.createStatement();
try {
- st.execute("INSERT INTO " + seqname + "(s)VALUES(NULL)");
+ st.execute("INSERT INTO " + seqname + "(s)VALUES(NULL)",
+ Statement.RETURN_GENERATED_KEYS);
final long r;
final ResultSet rs = st.getGeneratedKeys();
try {