google-app-engineplayframeworksiena

Build siena query using date comparation in playframework+gae


I'm using siena in a playframework app, also with 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.

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.


Solution

  • 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!