@Override
    public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
        final PredicateIndicator pi = l.getPredicateIndicator();
        if (belsDB.get(pi) == null)
            return super.getCandidateBeliefs(l, u);
        
        if (l.isVar()) {
            // all bels are relevant
            return iterator();
        } else {
            // get all rows of l's table
            try {
                String q = getSelect(l);
                if (logger.isLoggable(Level.FINE)) logger.fine("getRelevant query for "+l+": "+q);
                final ResultSet rs = conn.createStatement().executeQuery(q);
                return new Iterator<Literal>() {
                    boolean hasNext   = true;
                    boolean firstcall = true;
                    public boolean hasNext() {
                        if (firstcall) {
                            try {
                                hasNext = rs.next();
                            } catch (SQLException e) {
                                logger.log(Level.SEVERE, "SQL Error", e);
                            }
                            firstcall = false;
                        }
                        return hasNext;
                    }
                    public Literal next() {
                        try {
                            if (firstcall) {
                                hasNext = rs.next();
                                firstcall = false;
                            }
                            Literal l = resultSetToLiteral(rs,pi);
                            hasNext = rs.next();
                            if (!hasNext) rs.close();
                            return l;
                        } catch (SQLException e) {
                            logger.log(Level.SEVERE, "SQL Error", e);
                        }
                        return null;
                    }
                    public void remove() { 
                        logger.warning("remove in jdbc get relevant is not implemented!");  
                    }
                };
            } catch (SQLException e) {
                logger.log(Level.SEVERE, "SQL Error in getRelevant for "+l, e);
            }
        }
        return null;
    }