简体   繁体   English

使用PlayFramework + Gae中的日期比较构建Siena查询

[英]Build siena query using date comparation in playframework+gae

I'm using siena in a playframework app, also with google app engine. 我在playframework应用程序中使用了siena,也在与Google App Engine一起使用。 I would like to build a query to get entities filtering with a field "date" of type java.util.Date, if it's possible. 如果可能的话,我想构建一个查询以使用类型为java.util.Date的字段“ date”过滤实体。

I've tried with something like 我已经尝试过类似的东西

    List<MyEntity> matchdays = MyEntity.all()
            .filter("date", ">01/01/2011")
            .fetch();

But doesn't work. 但是不起作用。 I suppose we can't use operators in this kind of queries. 我想我们不能在这种查询中使用运算符。 Is there a way to do this? 有没有办法做到这一点?

Thank you in advance. 先感谢您。

Remember in a filter the > should be on the side of the field. 请记住,在过滤器中,>应该在字段的侧面。
Moreover, you want to compare to a date so don't pass a String but a Date (current Siena doesn't manage this automatic conversion). 此外,您希望与日期进行比较,因此不要传递字符串而是传递日期(当前的Siena不会管理此自动转换)。
Try something like: 尝试类似的方法:

List<MyEntity> matchdays = MyEntity.all()
        .filter("date>", new SimpleDateFormat("dd/MM/yyyy).parse("01/01/2011"))
        .fetch();

Tell me if you have any problem, I will look at it! 告诉我您是否有任何问题,我会解决的!

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

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