简体   繁体   English

日期查询不适用于Google App Engine Java

[英]Date Query not working on Google App Engine Java

      Date today = new Date();        
      Query query5 = pm.newQuery(TMS.class);
      query5.setFilter("start_date < date");
      query5.setFilter("end_date > date");
      query5.setFilter("emp_Id == id");
      query5.declareParameters("java.util.Date date,String id");
      List<TMS> result1 = (List<TMS>)query5.execute(today,session.getAttribute("emp_Id").toString());

Query gives all the result and the condition is not working.. It is not giving any error also. 查询给出所有结果,条件不起作用。它也不给出任何错误。 can any body give the solution? 有谁能提供解决方案?

I don't know for sure, but maybe it happens because there are some restrictions on queries. 我不确定,但是也许会发生,因为对查询有一些限制。

On GAE you can't use inequality filters on more than one property. 在GAE上,您不能对多个属性使用不等式过滤器。 You use operator LESS_THAN on "start_date" property and operator GREATER_THAN on "end_date" property. 您在“ start_date”属性上使用运算符LESS_THAN,在“ end_date”属性上使用运算符GREATER_THAN。 Maybe that's the problem. 也许这就是问题所在。

Check this out: http://code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries 检出此内容: http : //code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries

You are querying on multiple properties. 您正在查询多个属性。 You will need to create an index by defining it in your datastore.indexes file. 您需要通过在datastore.indexes文件中定义索引来创建索引。 Single property queries are only enabled by default. 单一属性查询仅在默认情况下启用。

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

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