有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Hibernate中生成subselect为什么?

我使用Hibernate和非常简单的Criteria API,但带有复杂的数据链接。 有时在加载实体后,我会在日志中看到以下SQL:

select * from ( select this_.ID as ID7_0_, from AAA.CUSTOMER this_ where this_.STATUS=? and this_.ID in (select this_.ID_CUSTOMER as y0_ from AAA.CUSTOMER_CONTACT this_ where this_.ID_CONTACT in (select this_.ID as y0_ from AAA.CONTACT this_ where this_.PHONE_NUMBER=?) and this_.ROLE=?) ) where rownum <= ?

但我不明白为什么Hibernate决定在不通过外键链接的情况下生成subselect(它们都指向hbm.xml)。为什么会有子选区?我只使用fetch=“select”或fetch=“join”

有什么想法吗


共 (1) 个答案

  1. # 1 楼答案

    这个问题已经不是热门话题了。有人手动进行了此子选择