0

我使用 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 决定生成子选择而不通过外键链接(它们都指向 hbm.xml)。为什么有子选择?我只使用 fetch="select" 或 fetch="join"。

有任何想法吗?

4

1 回答 1

0

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

于 2013-01-31T08:03:46.357 回答