开发者

Hibernate - native SQL + non-managed entities + collections

开发者 https://www.devze.com 2023-03-22 14:50 出处:网络
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 the

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:

  1. Use transformTuple() method to transform 'root' bean along with a single collection element.
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消