From f2be63ec19e613f0f78cfc7dfecd834511bdb936 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 2 May 2014 20:14:43 +0000 Subject: [PATCH] Choke usefully if we can't obtain last inserted id. --- .../com/samskivert/depot/impl/IdentityValueGenerator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java b/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java index cab2523..3e4b85e 100644 --- a/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java +++ b/src/main/java/com/samskivert/depot/impl/IdentityValueGenerator.java @@ -38,7 +38,11 @@ public class IdentityValueGenerator extends ValueGenerator public int nextGeneratedValue (Connection conn, DatabaseLiaison liaison, Statement stmt) throws SQLException { - return liaison.lastInsertedId(conn, stmt, _dm.getTableName(), _fm.getColumnName()); + Integer id = liaison.lastInsertedId(conn, stmt, _dm.getTableName(), _fm.getColumnName()); + if (id == null) throw new SQLException( + "Unable to obtain last inserted id [table=" + _dm.getTableName() + + ", column=" + _fm.getColumnName() + "]"); + return id; } @Override // from ValueGenerator