We're seeing some weirdness here, so let's log the original statement along
with the actual set of wanted and obtained keys when we have a mismatch.
This commit is contained in:
@@ -87,6 +87,7 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
Set<Key<T>> fetchKeys = new HashSet<Key<T>>();
|
Set<Key<T>> fetchKeys = new HashSet<Key<T>>();
|
||||||
|
|
||||||
PreparedStatement stmt = _builder.prepare(conn);
|
PreparedStatement stmt = _builder.prepare(conn);
|
||||||
|
String stmtString = stmt.toString(); // for debugging
|
||||||
try {
|
try {
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -111,7 +112,7 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
JDBCUtil.close(stmt);
|
JDBCUtil.close(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadAndResolve(conn, allKeys, fetchKeys, entities);
|
return loadAndResolve(conn, allKeys, fetchKeys, entities, stmtString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
fetchKeys.add(key);
|
fetchKeys.add(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadAndResolve(conn, _keys, fetchKeys, entities);
|
return loadAndResolve(conn, _keys, fetchKeys, entities, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<Key<T>> _keys;
|
protected Collection<Key<T>> _keys;
|
||||||
@@ -228,7 +229,8 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<T> loadAndResolve (Connection conn, Collection<Key<T>> allKeys,
|
protected List<T> loadAndResolve (Connection conn, Collection<Key<T>> allKeys,
|
||||||
Set<Key<T>> fetchKeys, Map<Key<T>, T> entities)
|
Set<Key<T>> fetchKeys, Map<Key<T>, T> entities,
|
||||||
|
String origStmt)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
// if we're fetching a huge number of records, we have to do it in multiple queries
|
// if we're fetching a huge number of records, we have to do it in multiple queries
|
||||||
@@ -242,11 +244,11 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
keyCount -= keys.size();
|
keyCount -= keys.size();
|
||||||
loadRecords(conn, keys, entities);
|
loadRecords(conn, keys, entities, origStmt);
|
||||||
} while (keyCount > 0);
|
} while (keyCount > 0);
|
||||||
|
|
||||||
} else if (fetchKeys.size() > 0) {
|
} else if (fetchKeys.size() > 0) {
|
||||||
loadRecords(conn, fetchKeys, entities);
|
loadRecords(conn, fetchKeys, entities, origStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T> result = new ArrayList<T>();
|
List<T> result = new ArrayList<T>();
|
||||||
@@ -259,7 +261,8 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadRecords (Connection conn, Set<Key<T>> keys, Map<Key<T>, T> entities)
|
protected void loadRecords (Connection conn, Set<Key<T>> keys, Map<Key<T>, T> entities,
|
||||||
|
String origStmt)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
_builder.newQuery(new SelectClause<T>(_type, _marsh.getFieldNames(),
|
_builder.newQuery(new SelectClause<T>(_type, _marsh.getFieldNames(),
|
||||||
@@ -276,8 +279,8 @@ public abstract class FindAllQuery<T extends PersistentRecord>
|
|||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
if (cnt != keys.size()) {
|
if (cnt != keys.size()) {
|
||||||
log.warning("Row count mismatch in second pass [query=" + stmt +
|
log.warning("Row count mismatch in second pass [origQuery=" + origStmt +
|
||||||
", wanted=" + keys.size() + ", got=" + cnt +
|
", wanted=" + keys + ", got=" + entities.keySet() +
|
||||||
", dups=" + dups + "]");
|
", dups=" + dups + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user