App engine datastore - query on Enum fields.
Posted
by Gopi
on Stack Overflow
See other posts from Stack Overflow
or by Gopi
Published on 2010-02-28T03:26:01Z
Indexed on
2010/03/22
6:21 UTC
Read the original article
Hit count: 457
I am using GAE(Java) with JDO for persistence.
I have an entity with a Enum field which is marked as @Persistent and gets saved correctly into the datastore (As observed from the Datastore viewer in Development Console). But when I query these entities putting a filter based on the Enum value, it is always returning me all the entities whatever value I specify for the enum field.
I know GAE java supports enums being persisted just like basic datatypes. But does it also allow retrieving/querying based on them? Google search could not point me to any such example code.
Details:
I have printed the Query just before being executed. So in two cases the query looks like -
SELECT FROM com.xxx.yyy.User WHERE role == super ORDER BY key desc RANGE 0,50
SELECT FROM com.xxx.yyy.User WHERE role == admin ORDER BY key desc RANGE 0,50
Both above queries return me all the User entities from datastore in spite of datastore viewer showing some Users are of type 'admin' and some are of type 'super'.
© Stack Overflow or respective owner