As a developer, I love this feature, as it helps the developers to transform the returned rows to List
, Map
, or user-defined Bean.
Now we will take a look at three scenarios of the demonstration code that will convert the records returned by hibernate to List
, Map
, and Bean.
Here, we use the Transformers
class to provide the transforming mechanism to criteria
.
All the demos up to this point show that if we use the criteria.list()
method, the resultant data is always returned in List
. However, you can still use Transformers.TO_LIST
in criteria, as follows:
criteria.setResultTransformer(Transformers.TO_LIST);
This means that every row in the result will be represented as a List
.