Good point. And to that, I'm now trying and getting better results with the 
code below. Deleting nevertheless just isn't as snappy as I thought. 


public void deleteTmpBlobAll_FromTask(long taskId) {
    log.info("BlobTmpJdo.deleteTmpBlobAll(): deleting all the tmp blob records. 
taskId=" + taskId);
    doSomeExist(); // output the total to log
    int i=0; 
    do { // batch query, otherwise timeout happens
      log.info("deleteTmpBlobAll_FromTask() loop index i=" + i);
      delteTmpBlobAll(1000);
      i++;
    } while (doSomeExist());
    new Db_Feed_TaskQue(sp).deleteTask(taskId);
  }

  public void delteTmpBlobAll(int limit) {
    PersistenceManager pm = sp.getPersistenceManager();
    try {
      javax.jdo.Query q = pm.newQuery("select id from " + 
BlobTmpJdo.class.getName());
      q.setRange(0, limit);
      List<String> results = (List<String>) q.execute();
      Iterator<String> itr = results.iterator();
      while(itr.hasNext()) {
        String id = itr.next();
        delete(id);
      }
    } catch (Exception e) {
      log.severe("delteTmpBlobAll(): ERROR: " + e.toString());
      e.printStackTrace();
    } finally {
      pm.close();
    }
  }

  public boolean doSomeExist() {
    int size = 0;
    PersistenceManager pm = sp.getPersistenceManager();
    try {
      javax.jdo.Query q = pm.newQuery("select id from " + 
BlobTmpJdo.class.getName());
      q.setRange(0, 10);
      List<String> ids = (List<String>) q.execute();      
      size = ids.size();
      q.closeAll();
    } catch (Exception e) { 
      log.log(Level.SEVERE, "", e);
    } finally {
      pm.close();
    }
    log.info("BlobTmpJdo.getTotal() total=" + size);
    boolean b = false;
    if (size > 0) {
      b = true;
    }
    return b;
  }

  private void delete(String id) {
    PersistenceManager pm = sp.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    try {
      tx.begin();
      BlobTmpJdo btj = pm.getObjectById(BlobTmpJdo.class, id);
      pm.deletePersistent(btj);
      tx.commit();
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      pm.close();
    }

Brandon Donnelson
http://gwt-examples.googlecode.com

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/VDJ3ZHRMUDZXVE1K.
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