Filter on several IDs

27 views
Skip to first unread message

Sydney

unread,
Sep 22, 2012, 12:37:03 PM9/22/12
to twig-p...@googlegroups.com

I ran the following query, and got an exception:

ObjectDatastore datastore = new AnnotationObjectDatastore(false);
List<Long> fanIds = new ArrayList<Long>();
fanIds.add(1l);
List<Fan> fans = datastore.find().type(Fan.class).activate(0)
        .addFilter("id", FilterOperator.IN, fanIds).returnAll().now();

The Fan entity has an id property annotated with @Id.

java.lang.IllegalArgumentException: @Id field must be stored as a Number or String but was class java.util.ArrayList. Use @Type to define the stored type and configure a type converter whichcan handle the conversion in both directions.
    at com.google.code.twig.standard.StandardCommonLoadCommand.idToKey(StandardCommonLoadCommand.java:79)
    at com.google.code.twig.standard.StandardCommonFindCommand.addFilter(StandardCommonFindCommand.java:100)
    at com.google.code.twig.standard.StandardRootFindCommand.addFilter(StandardRootFindCommand.java:28)

John Patterson

unread,
Sep 22, 2012, 10:20:02 PM9/22/12
to twig-p...@googlegroups.com
Just do a load.ids(fanIds).now()
Reply all
Reply to author
Forward
0 new messages