子选择获取策略在Hibernate中的嵌套集合上不起作用

子选择获取策略在Hibernate中的嵌套集合上不起作用,hibernate,Hibernate,我有3个实体和它们的嵌套集合,如下所示: 实体A包含B的集合,实体B包含C的集合 我需要获取实体a的完整对象图列表。当我将获取策略设置为subselect for collection of B和collection of C时,实际上通过单个查询只读取B的集合。每个类型B的实体都通过单独的查询读取每个C集合,就像在那里选择了抓取策略一样 因此,我预计: select ... from A select ... from B where a_id in (select id from A) se

我有3个实体和它们的嵌套集合,如下所示: 实体A包含B的集合,实体B包含C的集合

我需要获取实体a的完整对象图列表。当我将获取策略设置为subselect for collection of B和collection of C时,实际上通过单个查询只读取B的集合。每个类型B的实体都通过单独的查询读取每个C集合,就像在那里选择了抓取策略一样

因此,我预计:

select ... from A select ... from B where a_id in (select id from A) select ... from C where b_id in (select id from B where a_id in (select id from A)) 但事实上:

select ... from A select ... from B where a_id in (select id from A) select ... from C where b_id = ? select ... from C where b_id = ? ... select ... from C where b_id = ?
嵌套子选择是否有任何限制?

问题已经确定-映射到数据库的实体具有getHashCode的自定义实现,该实现基于所有内部成员(包括集合)的值计算哈希代码。当Hibernate为实体B调用getHashCode时,集合C还没有被读取,但它是获取哈希所必需的。因此,将执行一个单独的查询来获取当前对象B的C集合