query specified join fetching, but the owner of the fetched association was not present in the select list

后端 未结 2 996
不知归路
不知归路 2020-12-14 13:33

I\'m selecting two id columns but get error specified:

org.hibernate.QueryException: **query specified join fetching, but the owner of the fetched associatio         


        
2条回答
  •  不思量自难忘°
    2020-12-14 14:26

    Use regular join instead of join fetch (by the way, it's inner by default):

    String hql = " select ec.id as entityChangeId, r.id as revisionId from EntityChange as ec " + 
            " join ec.revision as r " + ...
    

    As error message tells you, join fetch doesn't make sense here, because it's a performance hint that forces eager loading of collection.

提交回复
热议问题