Transactor tx = (Transactor) Thread.currentThread ();
    public synchronized String generateMaxID (DbMapping map) throws Exception {	Transactor tx = (Transactor) Thread.currentThread ();	// tx.timer.beginEvent ("generateID "+map);	QueryDataSet qds = null;	String retval = null;	try {	    Connection con = map.getConnection ();	    String q = "SELECT MAX("+map.getIDField()+") FROM "+map.getTableName();	    qds = new QueryDataSet (con, q);	    qds.fetchRecords ();	    // check for empty table	    if (qds.size () == 0) {	        long currMax = map.getNewID (0);	        retval = Long.toString (currMax);	    } else {	        long currMax = qds.getRecord (0).getValue (1).asLong ();	        currMax = map.getNewID (currMax);	        retval = Long.toString (currMax);	    }	} finally {	    // tx.timer.endEvent ("generateID "+map);	    if (qds != null) try {	        qds.close ();	    } catch (Exception ignore) {}	}	return retval;    }