Hibernate HQL join fetch not recursively fetching

后端 未结 7 583
挽巷
挽巷 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:22

    Since you have already specified FetchType.EAGER for both networkCodes and operators, whenever you will query domain, hibernate will load both networkCodes and operators. That's the whole idea of EAGER fetching mode

    So you could change your query simple to following:

    private static final String FIND
        = "SELECT DISTINCT domain"
        + " FROM Domain domain"
        + " WHERE domain.domainId = :domainId";
    

    API details here

    Cheers !!

提交回复
热议问题