Wrapper classes are very convenient, but creating too many custom wrapper objects can
clutter a code base. To get around this but still benefit from type-safety, the criteria API
provides support for retrieving results as tuples. A tuple is an ordered list of elements—in
this case, results. Using the meta-model, you specify what values are selected and then re-
trieve the values from the tuple. You can also retrieve values using a string key, identifier,
and so on. The code in the following listing retrieves the same winning bid summary data,
but it uses a tuple to report the results.
Listing 11.9. Selecting values and retrieving the result as a tuple
From the code in this listing, you can see that using a tuple is relatively straightforward and
not very different from a wrapped object. The elements in the tuple can be accessed using
the meta-model, index, or string keys. For illustration, the item names are logged at the end
of the method to demonstrate how values can be retrieved.