Extending the ECOrganizationQuery and ECUserQuery objects

When you use the member search feature, you can extend the query objects.

About this task

You can extend the query objects by specifying several additional attributes:

  • setOrderBy() Set the ORDERBY field for the query. This can be any field from any supported table.
  • setStart() Set the start point for the result set, to be used when paging through results.
  • setMaxResults() Set the maximum number of results to return.

Performance considerations

Keep in mind that this query object allows for formulating some very expensive queries. Any query that searches using not case-sensitive or 'contains' or 'ends-with' queries will perform a table scan. If you know that you will be supporting not case-sensitive searches on fields, then you can significantly improve performance by introducing an UPPERCASE index for the field. For the 'contains' or 'ends-with' queries, there is nothing that you can do to improve performance. Avoid these queries wherever possible. Queries using 'starts-with' can use the index.

Extending an existing query object

This section describes how to customize some typical scenarios. It assumes that you create a search query that extends from the ECUserQuery object.

Example: Extend the supported JOIN tables

If you have an additional table on which you want to base a search, you can add it to the query by extending the getJoinInformation() method:

protected Vector getJoinInformation() {
  Vector vecJoinInformation = super.getJoinInformation();
  new JoinInformation(
  new WhereClauseJoinCondition(
  return vecJoinInformation;

In this example, the default join information is extended with a JOIN clause for a new table called CUSTOMTABLE. This table happens to have a foreign key to USERS, so the JOIN condition is straightforward.

Example: Extend the SELECT clause

You should always keep the USERS.USERS_ID as the first attribute returned from the query. And you should carefully think about any change that would return more information, because of the potential issues with access control. However, if you need to have more information returned, and you can be sure that this query will not violate any access control, then you can extend the SELECT clause as follows:

protected TableField[] getSelectTableFields() {
  TableField[] selectTableFields = new TableField[2];
  selectTableFields[0] = new TableField("USERS", "USERS_ID");
  selectTableFields[1] = new TableField("USERS", "DN");
  return selectTableFields;

Remember that the result from executing the query is a Vector of Vectors. With this change, the internal vector will now have two elements - entry 0 will hold the USERS.USERS_ID, entry 1 will hold the USERS.DN.

Creating a query object

Creating your own query object follows the same pattern as extending an existing query object. There are only two methods to override - getSelectTableFields() and getJoinInformation().