Filtering records in app-engine (Java)

Posted by Manjoor on Stack Overflow See other posts from Stack Overflow or by Manjoor
Published on 2010-04-29T06:40:05Z Indexed on 2010/04/29 6:47 UTC
Read the original article Hit count: 355

I have following code running perfectly. It filter records based on single parameter.

public List<Orders> GetOrders(String email)
 {
     PersistenceManager pm = PMF.get().getPersistenceManager();
     Query query = pm.newQuery(Orders.class); 
     query.setFilter("Email == pEmail"); 
     query.setOrdering("Id desc"); 
     query.declareParameters("String pEmail");
     query.setRange(0,50);       
     return (List<Orders>) query.execute(email);
 }

Now i want to filter on multiple parameters. sdate and edate is Start Date and End Date. In datastore it is saved as Date (not String).

public List<Orders> GetOrders(String email,String icode,String sdate, String edate)
 {
     PersistenceManager pm = PMF.get().getPersistenceManager();
     Query query = pm.newQuery(Orders.class); 
     query.setFilter("Email == pEmail");
     query.setFilter("ItemCode == pItemCode");
     query.declareParameters("String pEmail");
     query.declareParameters("String pItemCode");
           .....//Set filter and declare other 2 parameters
           .....// 
           ......
     query.setRange(0,50);       
     query.setOrdering("Id desc");
     return (List<Orders>) query.execute(email,icode,sdate,edate);
 }

Any clue?

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about java