@Gamlor不,我根本没有排序。代码如下:
public static ObjectSet<PostedMessage> getMessagesBetweenDates(
Calendar after,
Calendar before,
ObjectContainer db) {
if (after == null || before == null || db == null) {
return null;
}
Query q = db.query(); //db is pre-configured to use SNAPSHOT mode.
q.constrain(PostedMessage.class);
Constraint from = q.descend("timeRecieved").constrain(new Long(after.getTimeInMillis())).greater().equal();
q.descend("timeRecieved").constrain(new Long(before.getTimeInMillis())).smaller().equal().and(from);
ObjectSet<EmailMessage> results = q.execute();
return results;
}
该方法的参数如下:
之后 = 2011 年 9 月 13 日 10:55:55
之前 = 2011 年 9 月 13 日 10:56:10
而且我希望在“之后”和“之前”之间只返回 10 个 PostedMessages。(我正在生成虚拟 PostedMessage,timeReceived 每次增加 1 秒。)