code: public void appendExists(Filter<S> filter) throws FetchException {
          mStatementBuilder.append(" WHERE ");
          mStatementBuilder.append("EXISTS (SELECT * FROM");
  
          JDBCStorableInfo<S> info;
  
          final JDBCRepository repo = mStatementBuilder.getRepository();
          try {
              info = repo.examineStorable(filter.getStorableType());
          } catch (RepositoryException e) {
              throw repo.toFetchException(e);
          }
  
          JoinNode jn;
          try {
              JoinNodeBuilder jnb =
                  new JoinNodeBuilder(repo, info, mAliasGenerator);
              filter.accept(jnb, null);
              jn = jnb.getRootJoinNode();
          } catch (UndeclaredThrowableException e) {
              throw repo.toFetchException(e);
          }
  
          jn.appendFullJoinTo(mStatementBuilder);
  
          mStatementBuilder.append(" WHERE ");
  
          {
              int i = 0;
              for (JDBCStorableProperty<S> property : info.getPrimaryKeyProperties().values()) {
                  if (i > 0) {
                      mStatementBuilder.append(" AND ");
                  }
                  mStatementBuilder.append(mJoinNode.getAlias());
                  mStatementBuilder.append('.');
                  mStatementBuilder.append(property.getColumnName());
                  mStatementBuilder.append('=');
                  mStatementBuilder.append(jn.getAlias());
                  mStatementBuilder.append('.');
                  mStatementBuilder.append(property.getColumnName());
                  i++;
              }
          }
  
          mStatementBuilder.append(" AND (");
  
          WhereBuilder<S> wb = new WhereBuilder<S>(mStatementBuilder, jn, mAliasGenerator);
  
          FetchException e = filter.accept(wb, null);
          if (e != null) {
              throw e;
          }
  
          // Transfer property filters so that the values are extracted properly.
          mPropertyFilters.addAll(wb.mPropertyFilters);
          mPropertyFilterNullable.addAll(wb.mPropertyFilterNullable);
  
          mStatementBuilder.append(')');
          mStatementBuilder.append(')');
      }
docs: Generate SQL of the form "WHERE EXISTS (SELECT * FROM ...)"  This is
  necessary for DELETE statements which operate against joined tables.