Hibernate HQL join fetch not recursively fetching

后端 未结 7 591
挽巷
挽巷 2020-12-30 05:07

I have the following query and method

private static final String FIND = \"SELECT DISTINCT domain FROM Domain domain LEFT OUTER JOIN FETCH domain.operators L         


        
7条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 05:18

    You marked your associations EAGER. So, whatever you do in your query, Hibernate will load all the associated domains and network codes of the loaded domains. And it will load the domains and network codes of the additional domains, etc. etc. until all collection loads return empty collections or entities that have already been loaded.

    To avoid that, make your collections lazy (as they are by default). Then loading a domain with its operators and its network codes will load just that.

提交回复
热议问题