@Override
public List<Event> findByOwnerId(PartakeConnection con, String userId, EventFilterCondition criteria, int offset, int limit) throws DAOException {
String draftSql = conditionClauseForCriteria(criteria);
Postgres9StatementAndResultSet psars = indexDao.select((Postgres9Connection) con,
"SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ownerId = ? " + draftSql + " ORDER BY beginDate DESC OFFSET ? LIMIT ?",
new Object[] { userId, offset, limit });
Postgres9IdMapper<Event> idMapper = new Postgres9IdMapper<Event>((Postgres9Connection) con, mapper, entityDao);
try {
ArrayList<Event> events = new ArrayList<Event>();
DataIterator<Event> it = new Postgres9DataIterator<Event>(idMapper, psars);
while (it.hasNext()) {
Event event = it.next();
if (event == null)
continue;
events.add(event);
}
return events;
} finally {
psars.close();
}
}