开发者

Build siena query using date comparation in playframework+gae

开发者 https://www.devze.com 2023-04-01 08:15 出处:网络
I\'m using siena in a playframework app, also with google开发者_Go百科 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 possib

I'm using siena in a playframework app, also with google开发者_Go百科 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.

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).
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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号