This chapter pertains to selecting SQLTemplates that fetch a single result set. By default the returned result is a List of DataRows or Persistent objects, depending on how the query was configured. However SQLTemplate is much more powerful and can be set up to fetch lists of scalars, and lists of Object instances with an arbitrary mix of objects and scalars.
To get either DataObjects or DataRows, not much configuration is needed:
To select a list of scalar values, you will need to use a SQLResult class to tell Cayenne how to deal with it:
Or if the query nature guarantees only a single row in the result (aggregate query), do this:
SQLResult can be used to fetch a mix of objects and scalars. In this case the result will be Object that contains scalars and objects in the order they were configured in SQLResultSetMapping: