q = new StringBuffer("SELECT count(*) FROM ").append(table) .append(rel.buildQuery(home, home.getNonVirtualParent(), null, " WHERE ", false)) .toString();
q = b.append(rel.buildQuery(home, home.getNonVirtualParent(), null, " WHERE ", false)).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 = new StringBuffer("SELECT count(*) FROM ").append(table).append(" ")                                                                 .append(home.getSubnodeRelation())                                                                 .toString();                } else {                    // let relation object build the query                    q = new StringBuffer("SELECT count(*) FROM ").append(table)                                                                 .append(rel.buildQuery(home,                                                                                        home.getNonVirtualParent(),                                                                                        null,                                                                                        " WHERE ",                                                                                        false))                                                                 .toString();                }                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;        }    }