Whoops! My last edit didn't actually work, it ended up falling back.
This works, but mdb is going to move the special caseyness inside the Liaison.
This commit is contained in:
@@ -6,11 +6,11 @@ package com.samskivert.depot.impl;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.ResultSetMetaData;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
import com.samskivert.jdbc.DatabaseLiaison;
|
import com.samskivert.jdbc.DatabaseLiaison;
|
||||||
|
import com.samskivert.jdbc.MySQLLiaison;
|
||||||
import com.samskivert.depot.annotation.GeneratedValue;
|
import com.samskivert.depot.annotation.GeneratedValue;
|
||||||
|
|
||||||
import static com.samskivert.depot.Log.log;
|
import static com.samskivert.depot.Log.log;
|
||||||
@@ -46,14 +46,8 @@ public class IdentityValueGenerator extends ValueGenerator
|
|||||||
// if this JDBC driver supports getGeneratedKeys, use it!
|
// if this JDBC driver supports getGeneratedKeys, use it!
|
||||||
if (stmt != null && conn.getMetaData().supportsGetGeneratedKeys()) {
|
if (stmt != null && conn.getMetaData().supportsGetGeneratedKeys()) {
|
||||||
ResultSet rs = stmt.getGeneratedKeys();
|
ResultSet rs = stmt.getGeneratedKeys();
|
||||||
while (rs.next()) {
|
if (rs.next()) {
|
||||||
ResultSetMetaData rsMetaData = rs.getMetaData();
|
return rs.getInt((liaison instanceof MySQLLiaison) ? "GENERATED_KEY" : column);
|
||||||
int columnCount = rsMetaData.getColumnCount();
|
|
||||||
for (int ii = 1; ii <= columnCount; ii++) {
|
|
||||||
if (column.equals(rsMetaData.getColumnName(ii))) {
|
|
||||||
return rs.getInt(ii);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return liaison.lastInsertedId(conn, _dm.getTableName(), column);
|
return liaison.lastInsertedId(conn, _dm.getTableName(), column);
|
||||||
|
|||||||
Reference in New Issue
Block a user