Use new smarter DatabaseLiaison.lastInsertedId.
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.samskivert</groupId>
|
<groupId>com.samskivert</groupId>
|
||||||
<artifactId>samskivert</artifactId>
|
<artifactId>samskivert</artifactId>
|
||||||
<version>1.7.1</version>
|
<version>1.8-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
|
|||||||
@@ -42,15 +42,7 @@ public class IdentityValueGenerator extends ValueGenerator
|
|||||||
public int nextGeneratedValue (Connection conn, DatabaseLiaison liaison, Statement stmt)
|
public int nextGeneratedValue (Connection conn, DatabaseLiaison liaison, Statement stmt)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String column = _fm.getColumnName();
|
return liaison.lastInsertedId(conn, stmt, _dm.getTableName(), _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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from ValueGenerator
|
@Override // from ValueGenerator
|
||||||
|
|||||||
Reference in New Issue
Block a user