ObjectContainer oc;
oc.store(new Info(1));
oc.store(new Info(2));
oc.store(new Info(3));
List<Info> list=oc.query(Info.class);
列表是:
如何获得如下列表:
db4o
中是否有任何原生方法?
Collections.reverse(list)
抛出java.lang.UnsupportedOperationException
。
答案 0 :(得分:0)
您可以通过Building SODA Queries实现此目的。
构建您的查询,如
ObjectContainer oc = Db4o.openFile("mydb.yap");
Query query = oc.query();
query.constrain(Info.class);
query.descend("id").orderDescending();
ObjectSet<Info> resultSet = query.execute();
// ResultSet would be order desending by id
while(resultSet.hasNext()){
Info info = resultSet.next();
info.getId() ;
}