code: private QueryImpl makeQuery(Session session) throws InvalidQueryException, RepositoryException
     {
        StatementContext context = new StatementContext();
        context.statement = new StringBuilder("SELECT * FROM ");
        context.statement.append(JCROrganizationServiceImpl.JOS_USERS_NODETYPE);
  
        if (query.getUserName() != null)
        {
           addStringStatement(context, UserProperties.JOS_USER_NAME, query.getUserName());
        }
  
        if (query.getFirstName() != null)
        {
           addStringStatement(context, UserProperties.JOS_FIRST_NAME, query.getFirstName());
        }
  
        if (query.getLastName() != null)
        {
           addStringStatement(context, UserProperties.JOS_LAST_NAME, query.getLastName());
        }
  
        if (query.getEmail() != null)
        {
           addStringStatement(context, UserProperties.JOS_EMAIL, query.getEmail());
        }
  
        if (query.getFromLoginDate() != null)
        {
           addDateStatement(context, UserProperties.JOS_LAST_LOGIN_TIME, ">=", query.getFromLoginDate());
        }
  
        if (query.getToLoginDate() != null)
        {
           addDateStatement(context, UserProperties.JOS_LAST_LOGIN_TIME, "<=", query.getToLoginDate());
        }
  
        if (status != UserStatus.ANY)
        {
           context.statement.append(" AND ").append(JCROrganizationServiceImpl.JOS_DISABLED);
           if (status == UserStatus.ENABLED)
              context.statement.append(" IS NULL");
           else
              context.statement.append(" IS NOT NULL");
        }
  
        return (QueryImpl)session.getWorkspace().getQueryManager().createQuery(context.statement.toString(), Query.SQL);
     }
docs: Transforms {@link org.exoplatform.services.organization.Query} into {@link Query}.