query.setFilter("chat == desiredRoom && date > earliest"); //(7)
query.setOrdering("date");
List<ChatMessage> messages = (List<ChatMessage>)query.execute(chat);
// Get the most recent message.
ChatMessage lastMessage = messages.get(messages.size() - 1);
ChatMessageList result = new ChatMessageList(chat, lastMessage.getDate());
result.addMessages(messages);
return result;
} finally {
persister.close();
}
}