Predefining and grouping a set of columns for a query
You can select and group columns to be used in a query (select/list) search by adding a parameter QueryGroup in the entity definition.
Each QueryGroup contains the columns to be used for a query. Each QueryGroup is identified by a unique name under which, the columns must be specified.
A global map QueryGroupMap is provided in the Entity class, which contains a unique query group name and attributes corresponding to the columns of the query group. This map is populated when entity repository is loaded.
Note: The QueryGroup name must be not be blank. When
adding a query group name to the map, check whether the name already
exists in the map.
Each entity can have multiple such query groups, which are defined under a parameter QueryGroups:
<Entity>
<QueryGroups>
<QueryGroup Name="PasswordQueryGroup">
<Column Name="PASSWORD"/>
<Column Name="IS_PASSWORD_ENCRYPTED"/>
<Column Name="SALT"/>
</QueryGroup>
<QueryGroup Name="BusinessQueryGroup">
<Column Name="BUSINESS_KEY"/>
<Column Name="CONTACTADDRESS_KEY"/>
<ColumnName="BILLINGADDRESS_KEY"/>
</QueryGroup>
</QueryGroups>
</Entity>Any number of columns can be specified under the query group. However, columns must not be repeated for a query group.
Note: A column in a QueryGroup can be a part of other
QueryGroups. A query group must contain at least one valid column
and columns defined for a query group must exist in the entity. You
cannot add virtual columns to the query group.
To obtain a list of all columns that are part of a particular QueryGroup,
use the method getColumnSetForQueryGroup in the following format:
public Set getColumnSetForQueryGroup(String queryGroupName)The following methods also can be used along with specific parameters
to get a list of columns in a query group:
- selectWithWhereForQueryGroup
- listWithWhereForQueryGroup
For example,
public YFS_User selectWithWhereForQueryGroup(YFCDBContext ctx,
String aWhereClause, String queryGroupName) throws YFCDBException{
Set columns = getColumnSet(queryGroupName);
return selectWithWhere(ctx, aWhereClause, columns);
}