Use new smarter DatabaseLiaison.lastInsertedId.
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>com.samskivert</groupId>
|
||||
<artifactId>samskivert</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<version>1.8-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
||||
@@ -42,15 +42,7 @@ public class IdentityValueGenerator extends ValueGenerator
|
||||
public int nextGeneratedValue (Connection conn, DatabaseLiaison liaison, Statement stmt)
|
||||
throws SQLException
|
||||
{
|
||||
String column = _fm.getColumnName();
|
||||
// if this JDBC driver supports getGeneratedKeys, use it!
|
||||
if (stmt != null && conn.getMetaData().supportsGetGeneratedKeys()) {
|
||||
ResultSet rs = stmt.getGeneratedKeys();
|
||||
if (rs.next()) {
|
||||
return rs.getInt((liaison instanceof MySQLLiaison) ? "GENERATED_KEY" : column);
|
||||
}
|
||||
}
|
||||
return liaison.lastInsertedId(conn, _dm.getTableName(), column);
|
||||
return liaison.lastInsertedId(conn, stmt, _dm.getTableName(), _fm.getColumnName());
|
||||
}
|
||||
|
||||
@Override // from ValueGenerator
|
||||
|
||||
Reference in New Issue
Block a user