public int getNumTaxonResults(String taxonName, String whereClause) {
   StringBuffer query = new StringBuffer(getCountTaxonQuery());
   if (whereClause != null) {
     query.append(" and ").append(whereClause);
   }
   try {
     // TODO check parameter substitution
     Query sessionQuery = createTaxonQuery(query.toString(), taxonName);
     lastQuery = query.toString();
     Iterator iter = sessionQuery.getResultList().iterator();
     return MorphbankConfig.getIntFromQuery(iter.next());
   } catch (Exception e) {
     System.err.println("exception");
     System.err.println("Query " + query.toString());
     e.printStackTrace(System.err);
     return 0;
   }
 }
 public Response processUpdate(Credentials requestCredentials, ObjectList update) {
   EntityTransaction tx = null;
   EntityManager em = null;
   boolean localTransaction = false;
   mapper =
       new UpdateObjectsFromXml(requestCredentials, update, MorphbankConfig.getRemoteServer());
   try { // add objects to database
     // TODO process updates one object per transaction!
     //			em = MorphbankConfig.getEntityManager();
     //			tx = em.getTransaction();
     //			if (!tx.isActive()) {
     //				localTransaction = true;
     //				tx.begin();
     //			}
     mapper.processObjects();
     //			if (localTransaction) tx.commit();
   } catch (Exception e) {
     e.printStackTrace();
     mapper.reportSuccess(null, null);
     if (localTransaction) tx.rollback();
   }
   return finalizeResponse(mapper.getResponse());
 }
 public Query createTaxonQuery(String queryString, String taxonName) {
   Query query = MorphbankConfig.getEntityManager().createNativeQuery(queryString.toString());
   query.setParameter(1, taxonName);
   return query;
 }