I found what was wrong. It is a really good reason never to use
deprecated API anymore.

2009-12-1 is new Date(109, 11, 1);

But not new Date(2009,12,1) or new Date(9,12,1) or new Date(109,12,1)



On Jan 16, 2:17 pm, Max <max.seven....@gmail.com> wrote:
> I just seen that my last code is working!
>
> Only first filder is working.
>                 query.addFilter("cid", Query.FilterOperator.EQUAL,
> 1111l);
>
> Second filter is ignored.
>                 query.addFilter("ctime",
> Query.FilterOperator.GREATER_THAN_OR_EQUAL, new Date(2009, 12,
> 1).getTime());
>
> How should I specify dates ?
>
> On Jan 16, 2:13 pm, Max <max.seven....@gmail.com> wrote:
>
> >                 DatastoreService ds = 
> > DatastoreServiceFactory.getDatastoreService();
>
> >                 Query query = new Query("Table1");
> >                 query.addFilter("cid", Query.FilterOperator.EQUAL, 1111l);
>
> > // was not very clear documented how dates are saved in DB
> > //              query.addFilter("ctime",
> > Query.FilterOperator.GREATER_THAN_OR_EQUAL, "DATE(2009, 12, 1)");
> > //              query.addFilter("ctime",
> > Query.FilterOperator.GREATER_THAN_OR_EQUAL, new Date(2009, 12, 1));
> >                 query.addFilter("ctime", 
> > Query.FilterOperator.GREATER_THAN_OR_EQUAL,
> > new Date(2009, 12, 1).getTime());
> >                 query.addSort("ctime");
> >                 query.setKeysOnly();
>
> >                 FetchOptions options = FetchOptions.Builder.withLimit(1000);
> >                 PreparedQuery p1 = ds.prepare(query);
>
> >                 Iterable it = p1.asIterable(options);
>
> > I hope it will help someone.
>
> > On Jan 16, 12:53 pm, Max <max.seven....@gmail.com> wrote:
>
> > > Hi, I can't write JDO query but I can make that query in GQL
>
> > > SELECT __key__ FROM Table1 WHERE cid = 1111 and ctime >= DATE
> > > ('2009-12-1') ORDER BY ctime LIMIT 1000
>
> > > ------
>
> > >                 Query query = pm.newQuery("SELECT FROM " + 
> > > Table1.class.getName()
> > >                                 + " WHERE cid == cid1 && ctime >=
> > > ctime1 "
> > >                                 + " parameters Long cid1,
> > > java.util.Date ctime1 "
> > >                                 + " order by ctime "
> > >                                 + " RANGE 0, 10 ");
> > >                 List ids = (List) query.execute(1111l, new Date(2009, 12, 
> > > 1));
>
> > > JDO return nothing and error when I try something like
>
> > >                 Query query = pm.newQuery("SELECT key FROM " + 
> > > Table1.class.getName
> > > ()
> > >                                 + " WHERE cid == cid1 && ctime >=
> > > ctime1 "
> > >                                 + " parameters Long cid1,
> > > java.util.Date ctime1 "
> > >                                 + " order by ctime "
> > >                                 + " RANGE 0, 10 ");
> > >                 List ids = (List) query.execute(1111l, new Date(2009, 12, 
> > > 1));
>
> > > or
>
> > >                 Query query = pm.newQuery("SELECT __key__ FROM " +
> > > Table1.class.getName()
> > >                                 + " WHERE cid == cid1 && ctime >=
> > > ctime1 "
> > >                                 + " parameters Long cid1,
> > > java.util.Date ctime1 "
> > >                                 + " order by ctime "
> > >                                 + " RANGE 0, 10 ");
> > >                 List ids = (List) query.execute(1111l, new Date(2009, 12, 
> > > 1));
>
> > > Primary Key is "key"
>
> > > Cheers, Max
>
>
-- 
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-j...@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