From c099fb97bbd61a6058c4a2be65c1de0f158665b8 Mon Sep 17 00:00:00 2001 From: mdb Date: Sun, 24 Jul 2005 07:06:58 +0000 Subject: [PATCH] Return the last inserted id when inserting records. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1681 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/jdbc/JORARepository.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java b/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java index 04a60f5f..5523bff7 100644 --- a/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java +++ b/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java @@ -57,17 +57,18 @@ public abstract class JORARepository extends SimpleRepository * Inserts the supplied object into the specified table. The table * must be configured to store items of the supplied type. */ - protected void insert (final Table table, final Object object) + protected int insert (final Table table, final Object object) throws PersistenceException { - execute(new Operation() { + Integer iid = (Integer)execute(new Operation() { public Object invoke (Connection conn, DatabaseLiaison liaison) throws SQLException, PersistenceException { table.insert(object); - return null; + return new Integer(liaison.lastInsertedId(conn)); } }); + return iid.intValue(); } /**