The example from the test class is what you're looking for, just
replace the
String id field with Integer id;

@PersistenceCapable(detachable = "true")
@Version(strategy = VersionStrategy.VERSION_NUMBER)
public class Flight implements Serializable {
  private Integer id;
...

Indexes configured in datastore-indexes.xml could help speed up your
query returns, but if the field is the primary key, they're already
indexed...



On May 9, 1:04 am, mscwd01 <mscw...@gmail.com> wrote:
> Thanks for the reply. I'm actually using JDO so I create a Query and
> apply .setFilter() to it. The property I have is an int[] array, not a
> List, but I could change this if it means I can query the contents of
> the List.
>
> Importantly, I need the query to be as efficient as possible as I'm
> currently looping through the Array once the Entity is loaded which I
> assume is not very efficient.
>
> So what would be the best way to store 30 integers (Array or List) and
> how would you filter on it in a query using JDO? I wish to check for
> Entities which contain a single integer or multiple I.e. 2 or 2,3 and
> 4.
>
> I've tried looking through the JDO docs but I'm obviously missing
> something :(
>
> Thanks
>
> On May 9, 7:57 am, Nichole <nichole.k...@gmail.com> wrote:
>
>
>
> > You can use "contains" in JDO instead of SQL's IN(), but the
> > implementation is a separate query for each item in the list.
> > (http://code.google.com/appengine/docs/java/datastore/jdo/
> > queries.html).
> > There's also a limit of 30 to the number of items in the array.
>
> > This from appengine tests is expected to work:
>
> > Query q = pm.newQuery("select from " + Flight.class.getName() + "
> > where :ids.contains(id)");
> > List<Flight> flights = (List<Flight>) q.execute( Arrays.asList(key,
> > e1.getKey(), e2.getKey()) );
>
> > On May 8, 5:14 pm, mscwd01 <mscw...@gmail.com> wrote:
>
> > > Hey
>
> > > I have an entity with an Int Array and I would like to perform a query
> > > on the contents of the Array. For example, I would like to return
> > > entities which have a certain number within the array, I.e.
>
> > > Select * From MyObject Where numberArray contains 2
>
> > > Is this possible in any way, shape or form?
>
> > > Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to