Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreService


    //(" listWhere: " + ":" + qf + ":" + field + ":" + value + ":" + value.getClass().getName());


    Query q = new Query(table);
    q = q.addFilter(field,qf,value);
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        PreparedQuery pq = datastore.prepare(q) ;
    return pq.countEntities();
}
View Full Code Here


  {
          Throwable ex = null;  
   for (int ct = 0; ct < readTries;ct++)
{
try{  
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
     Query q = new Query(table);
        PreparedQuery pq = datastore.prepare(q) ;
    return pq.countEntities();

  }catch (com.google.appengine.api.datastore.DatastoreTimeoutException e){
  ex = e;
  if ((ct) == (readTries -3))
View Full Code Here

 
  static int readTries = 18;
  static long wtP = 350;
    public static Vector<JGNameValuePairs> list(String table)throws JGException
  {
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();


    JGNameValuePairs jn = null;
       Query q = new Query(table);
                ArrayList<Key> keys = new ArrayList<Key>();
        PreparedQuery pq = datastore.prepare(q) ;
    int ezt = pq.countEntities();

    if (ezt > fLimit)
      throw JGException.get("result_too_large"," Result too LARGE. Try narrowing query by adding more filters: " + ezt);
View Full Code Here

  }
 
  public static Transaction getTransaction(){
 
  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  Transaction trans = datastore.beginTransaction()  ;
  return trans;
  }
View Full Code Here

  return trans;
  }
 
    public static DatastoreService getDatastoreService(){
 
  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    return datastore;
  }
View Full Code Here

  static int fLimit = 999;
  static int dLimit = 100;
 
    public static void delete(String kind,Transaction trans)throws JGException
  {
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    FetchOptions fo = FetchOptions.Builder.withLimit(dLimit);
    fo.limit(dLimit);
    while (true){
   
     Query q = new Query(kind);
                ArrayList<Key> keys = new ArrayList<Key>();


                Iterator it = (datastore.prepare(q).asIterator(fo));
         if (it == null || !it.hasNext())
           break;
//new ArrayList
        Entity entity = null;
                int ct = 0;
                while (it.hasNext()) {
                  ct = ct + 1;
                  checkThread(ct);
                  entity = (Entity)it.next();
                        keys.add(entity.getKey());
                        /*      if (trans != null)
                  datastore.delete(trans,entity.getKey());
                else
                  datastore.delete(entity.getKey()); */
               
                }
                if (trans != null)
                  datastore.delete(trans,keys);
                else
                  datastore.delete(keys);
    }
        }
View Full Code Here

   for (int ct = 0; ct < readTries;ct++)
{
try{
  //        EntityManager em = EMF.get().createEntityManager();
//EntityTransaction tx = em.getTransaction();
           DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

  Transaction trans = datastore.beginTransaction()  ;
boolean suc = false;
try{

//tx.begin();
   
   
           checkThread();

         Key key = KeyFactory.createKey(pk,kind,id);
                datastore.delete(key);
trans.commit();
    suc = true;
                    return;
 
 
View Full Code Here

    public static void deleteById(String kind,long id)throws JGException
  {
   
     checkThread();
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

     Key key = KeyFactory.createKey(kind,id);
                datastore.delete(key);
        }
View Full Code Here

   
    if (!sqp.getConnection().getAutoCommit()){
      try{
     
      //(" WRUIT TAB ROW ? " + hash);
            DatastoreService datastore = JIQLGDataUtil.getDatastoreService();
           Transaction trans = datastore.beginTransaction();
           sqp.getConnection().setTransaction(trans);
           rid = JIQLGDataUtil.put(tn,hash,pk,datastore,trans);
      }finally{
        return ;
      }
View Full Code Here

  }


  @Override
  public int queryPosition(String encodedKey) {
    DatastoreService datastore=getDatastoreService();
    Entity player;
    try {
      player = datastore.get(KeyFactory.stringToKey(encodedKey));
      Query query=new Query(Player.class.getSimpleName());
      query.addFilter(TransportablePlayer.TOTAL_PROPERTY, Query.FilterOperator.GREATER_THAN,player.getProperty(TransportablePlayer.TOTAL_PROPERTY));
      return 1+datastore.prepare(query).countEntities(FetchOptions.Builder.withDefaults());
    } catch (EntityNotFoundException e) {
      e.printStackTrace();
      PlayerServiceImpl.LOG.log(Level.WARNING,"cannot find the player who want to query his position.");
      return -1;
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.DatastoreService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.