@Override
    public ResultPage<Account> search(final FindAccountRequest request) {
        final Condition notProcessingUser = ACCOUNT.PROCESSING_ACCOUNT.isFalse();
        final Condition filterConditions = NullSafe.getOrElseGet(
                expressionMapper,
                mapper -> mapper.apply(request.getExpression()),
                DSL::trueCondition);
        // Sort on user_id if no sort supplied
        final Collection<OrderField<?>> orderFields = JooqUtil.getOrderFields(FIELD_MAP, request, ACCOUNT.USER_ID);
        final int limit = JooqUtil.getLimit(request.getPageRequest(), true);
        final int offset = JooqUtil.getOffset(request.getPageRequest());

        return JooqUtil.contextResult(identityDbConnProvider, context -> {
            final List<Account> accounts = context
                    .select(ACCOUNT.asterisk(),
                            ACCOUNT_STATUS)
                    .from(ACCOUNT)
                    .where(notProcessingUser)
                    .and(filterConditions)
                    .orderBy(orderFields)
                    .offset(offset)
                    .limit(limit)
                    .fetch()
                    .map(RECORD_TO_ACCOUNT_MAPPER::apply);
            return ResultPage.createCriterialBasedList(accounts, request);
        });
    }
Create a derived field that represents the account state.
stroom-security/stroom-security-identity-db/src/main/java/stroom/security/identity/db/AccountDaoImpl.java