By default, lazy-loaded query result sets contain only repository IDs. If the required data is limited to a few properties, and those properties belong only to the primary table, you can modify lazy-loaded caching by embedding preloading hints in the RQL statement. The result set that is lazy-loaded into the cache includes those properties together with repository IDs
For example, the following RQL specifies to lazy-load the login property:
RepositoryView view = repository.getView("user");
// to display only logins, preload the login property
RqlStatement statement =
RqlStatement.parseRqlStatement("firstName = ?0 PROPERTY HINTS login");
Object params[] = new Object[1];
params[0] = "Maria";
RepositoryItem [] items = statement.executeQuery (view, params);You can also use the interface atg.repository.Repository to embed preloading hints in a query programmatically. The following code excerpt is equivalent to the RQL example shown above:
// Somehow, get the repository
Repository rep = getRepository();
RepositoryItemDescriptor desc = rep.getItemDescriptor("user");
// RepositoryView is a ParameterSupportView, so it supports parameters in queries
// This assumes advanced knowledge that the view is an instance of a
// ParameterSupportView
ParameterSupportView view = (ParameterSupportView)desc.getRepositoryView();
QueryBuilder qb = view.getQueryBuilder();
// firstName = 'Maria'
QueryExpression firstNameProp = qb.createPropertyQueryExpression("firstName");
QueryExpression parameterValue = qb.createParameterQueryExpression();
Query firstNameQuery = qb.createComparisonQuery
(firstNameProp, parameterValue, QueryBuilder.EQUALS);
// arguments
Object[] args = new Object[1];
args[0] = new String("Maria");
// preload "login" property in order to display it without loading full items
String [] precachedProperties = new String[1];
precachedProperties[0] = "login";
QueryOptions options = new QueryOptions(0, -1, null, precachedProperties);
RepositoryItem[] mariaItems = view.executeQuery(firstNameQuery, options, args);
