@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;
}
该方法的参数是如下:
后
= 13-09-2011十点55分55秒
之前= 13-09-2011 10 :56:10
而且我期望在“after”和“before”之间只返回10个PostedMessages。 (我生成的dummyMessage与timeReceived每增加1秒。)
你说你只是想要'前20',是你用来订购结果索引在数据库中的信息? – paul
是的,它被索引。我没有使用TA/TP。我正在使用SNAPSHOT查询模式。而前20,是因为,我想以分页的方式访问发布的消息。 –
Can Gamlor对此有何评论? –