q = "SELECT count(*) FROM "+table+" "+home.getSubnodeRelation();
q = new StringBuffer("SELECT count(*) FROM ") .append(table) .append(" ") .append(home.getSubnodeRelation()) .toString();
    public int countNodes (Node home, Relation rel) throws Exception {	// Transactor tx = (Transactor) Thread.currentThread ();	// tx.timer.beginEvent ("countNodes "+home);	if (rel == null || rel.otherType == null || !rel.otherType.isRelational ()) {	    // this should never be called for embedded nodes	    throw new RuntimeException ("NodeMgr.countNodes called for non-relational node "+home);	} else {	    int retval = 0;	    Connection con = rel.otherType.getConnection ();	    String table = rel.otherType.getTableName ();	    Statement stmt = null;	    try {		        String q = null;	        if (home.getSubnodeRelation() != null) {	            // use the manually set subnoderelation of the home node	            q = "SELECT count(*) FROM "+table+" "+home.getSubnodeRelation();	        } else {	            // let relation object build the query	            q = "SELECT count(*) FROM "+table + rel.buildQuery (home, home.getNonVirtualParent (), null, " WHERE ", false);	        }		        if (logSql)	            app.logEvent ("### countNodes: "+q);		        stmt = con.createStatement();	        ResultSet rs = stmt.executeQuery (q);	        if (!rs.next())	            retval = 0;	        else	            retval = rs.getInt (1);	    } finally {	        // tx.timer.endEvent ("countNodes "+home);	        if (stmt != null) try {	            stmt.close ();	        } catch (Exception ignore) {}	    }	    return rel.maxSize > 0 ? Math.min (rel.maxSize, retval) : retval;	}    }