An Introduction to Query Builders

A TIBCO Patterns query performs a search for records matching a particular set of values. To search for "John Smith", you build a query and perform the search. To search for "Jack Jones", you must build a new query. Every new search requires a new query be built. A query builder takes in a set of values to be matched and outputs a TIBCO Patterns query to match those values.

The TIBCO Patterns Java API provides two abstract classes that define a standard interface for query builders.

ANetricsQueryBuilder builds queries to match a flat record.
ANetricsCompoundQueryBuilder builds queries to match a compound record. For information about compound records, see Compound Records.

By implementing your query builder class as an extension of one of these classes, you can make your query builder usable in any application that is written to use one of these abstract classes. It is recommended that all applications doing record matching use one of these abstract classes to generate record matching queries.

The two abstract classes provided by the Java API provide methods that enable an implementation of a query to be adapted to new applications without code changes. Input and output data element names and table names can be remapped. The classes accept a number of input formats, taking care of the bookkeeping needed to deal with the different formats. You only need to define how to build the query, the rest of the functionality is provided by the abstract base class. This simplifies the writing of a new query builder.