Ah, entities.keySet() is misleading because it contains records that were found

in the cache as well as records loaded from earlier passes in cases where we
split our query up to avoid database breaking in() clause sizes. Now we track
exactly what we got this time around and report that.
This commit is contained in:
Michael Bayne
2008-09-12 01:55:54 +00:00
parent 2611a1076b
commit 98ac644ad9
@@ -269,19 +269,21 @@ public abstract class FindAllQuery<T extends PersistentRecord>
new KeySet<T>(_type, keys))); new KeySet<T>(_type, keys)));
PreparedStatement stmt = _builder.prepare(conn); PreparedStatement stmt = _builder.prepare(conn);
try { try {
Set<Key<T>> got = new HashSet<Key<T>>();
ResultSet rs = stmt.executeQuery(); ResultSet rs = stmt.executeQuery();
int cnt = 0, dups = 0; int cnt = 0, dups = 0;
while (rs.next()) { while (rs.next()) {
T obj = _marsh.createObject(rs); T obj = _marsh.createObject(rs);
if (entities.put(_marsh.getPrimaryKey(obj), obj) != null) { Key<T> key = _marsh.getPrimaryKey(obj);
if (entities.put(key, obj) != null) {
dups++; dups++;
} }
got.add(key);
cnt++; cnt++;
} }
if (cnt != keys.size()) { if (cnt != keys.size()) {
log.warning("Row count mismatch in second pass [origQuery=" + origStmt + log.warning("Row count mismatch in second pass", "origQuery", origStmt,
", wanted=" + keys + ", got=" + entities.keySet() + "wanted", keys, "got", got, "dups", dups, new Exception());
", dups=" + dups + "]", new Exception());
} }
} finally { } finally {