繁体   English   中英

对Google App Engine进行排序

[英]Sort Google App Engine

我希望从特定Merchant获得GAE的约会列表,并根据约会的日期时间进行排序( dateLog ):

PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "select from " + Appointment.class.getName();  
query += " where merchant == '" + session.getAttribute("merchant") + "'";
query += " order by dateLog desc range 0,5";
List<Appointment> appointment = (List<Appointment>) pm.newQuery(query).execute(); 

但是,它返回错误,并且我已经检查/多次检查多次,但无济于事。 有人可以帮忙吗? 我很沮丧

您应该在应用程序war/目录的WEB-INF/datastore-indexes.xml为数据存储指定建议的索引。 XML如下所示:

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes  autoGenerate="true">
  <datastore-index kind="Appointment" ancestor="false" source="manual">
    <property name="merchant" direction="asc"/> 
    <property name="dateLog" direction="desc"/> 
  </datastore-index>
</datastore-indexes>

参考: https : //developers.google.com/appengine/docs/java/config/indexconfig

如果您在上传到App Engine服务器之前测试了网址,则索引文件将自动生成。 在开发服务器中运行并点击显示错误的URL,它将生成文件,当您将其部署到App Engine服务器时,将建立索引,还有另一件事,这需要一些时间,您才能在Datastore Indexes(构建和服务)在Google App Engine管理控制台中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM