简体   繁体   中英

Hibernate - native SQL + non-managed entities + collections

This documentation chapter explains how to return non-managed entities for native queries. Is it possible 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM