簡體   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