diff --git a/src/java/com/samskivert/jdbc/JORARepository.java b/src/java/com/samskivert/jdbc/JORARepository.java index 15b9deee..48a3f154 100644 --- a/src/java/com/samskivert/jdbc/JORARepository.java +++ b/src/java/com/samskivert/jdbc/JORARepository.java @@ -163,18 +163,22 @@ public abstract class JORARepository extends SimpleRepository * First attempts to update the supplied object and if that modifies * zero rows, inserts the object into the specified table. The table * must be configured to store items of the supplied type. + * + * @return -1 if the object was updated, the last inserted id if it was + * inserted. */ - protected void store (final Table table, final T object) + protected int store (final Table table, final T object) throws PersistenceException { - execute(new Operation() { - public Object invoke (Connection conn, DatabaseLiaison liaison) + return execute(new Operation() { + public Integer invoke (Connection conn, DatabaseLiaison liaison) throws SQLException, PersistenceException { if (table.update(object) == 0) { table.insert(object); + return liaison.lastInsertedId(conn); } - return null; + return -1; } }); }