This documentation chapter explains how to return non-managed entities for native queries. Is it poss开发者_如何学Pythonible for those entities to have collections of other non-managed entities?
In theory - yes. You can write your own result transformer (loosely based on org.hibernate.transform.AliasToBeanResultTransformer
) that would:
- Use
transformTuple()
method to transform 'root' bean along with a single collection element. - Subsequently use
transformList()
to merge collection elements into matching parent beans.
In practice, however, it's much easier to actually map corresponding entities, even if you're only going to use it for retrieving the data from such a query.
精彩评论