From 9ebd2c677c08980d6bf7b65fa881f1663f205fe1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 2 May 2014 18:19:51 +0000 Subject: [PATCH] Use new smarter DatabaseLiaison.lastInsertedId. --- pom.xml | 2 +- .../samskivert/depot/impl/IdentityValueGenerator.java | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 6c147e4..a1ed134 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.samskivert samskivert - 1.7.1 + 1.8-SNAPSHOT com.google.guava diff --git a/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java b/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java index c65900a..c08c4f7 100644 --- a/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java +++ b/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java @@ -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