From be3649908bbb9cac8feefc27ac3b61220c980f8e Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Wed, 22 Aug 2007 20:30:20 +0000 Subject: [PATCH] Replace insane implementation with one that does not rely on the database to magically know in which order we want results returned. --- .../com/samskivert/jdbc/depot/FindAllQuery.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/FindAllQuery.java b/src/java/com/samskivert/jdbc/depot/FindAllQuery.java index eddfb50..5a58ae6 100644 --- a/src/java/com/samskivert/jdbc/depot/FindAllQuery.java +++ b/src/java/com/samskivert/jdbc/depot/FindAllQuery.java @@ -124,11 +124,16 @@ public abstract class FindAllQuery // and execute it try { ResultSet rs = stmt.executeQuery(); - for (Key key : fetchKeys) { - if (!rs.next()) { - throw new SQLException("Expecting more rows in result set."); - } - entities.put(key, _marsh.createObject(rs)); + int cnt = 0; + while (rs.next()) { + T obj = _marsh.createObject(rs); + entities.put(_marsh.getPrimaryKey(obj), obj); + cnt ++; + } + if (cnt != fetchKeys.size()) { + throw new SQLException( + "Row count mismatch in second pass [expectedCount=" + fetchKeys.size() + + ", actualCount=" + cnt + "]"); } } finally {