Hibernate - native SQL + unmanaged objects + collections

This documentation chapter explains how to return unmanaged objects for your own queries. Is it possible for these objects to have collections of other unmanaged objects?

+4
source share
1 answer

In theory, yes. You can write your own result transformer (based on org.hibernate.transform.AliasToBeanResultTransformer ), which:

  • Use the transformTuple() method to convert the 'root' bean along with one element of the collection.
  • Subsequently, use transformList() to combine the elements of the collection into the appropriate parent beans.

In practice, however, it is much easier to actually match the corresponding objects, even if you intend to use them only to retrieve data from such a query.

+1
source

All Articles