0


休止状態で結果を取得する際に問題がありました。
SnsUser、Participant、Interaction、Content の 4 つのテーブルがあります。SNSUser & Interaction には多対多の関係があり、Interaction と Content には多対一の関係があります。(SnsUser と Interation はマッピング クラスで参加者のセットを取得し、hibernate は多対多で行います)

HQLのように実行すると

from SnsUser s join fetch s.participants p join fetch p.interaction i join fetch i.content c where s.blessUid=1

(List(SnsUser)のリストを返す)

10行と言って、各行(つまり、SnsUser)には参加者として10行あります。

しかし、HQLのように実行すると

from Participant p join fetch p.snsUser s join fetch p.interaction i join fetch i.content c where s.blessUid=1

それは私に10行を与え、そこから関連するSnsUserを取得できます。しかし、実際のSQLクエリを見ると、両方とも同じです。なぜこのように振る舞うか...?

回答をいただければ幸いです。アル

4

1 に答える 1

0

I'm skeptic, both queries shouldn't be the same (one should be performed against the SnsUser table and the other should be performed against the Participant table).

And because I only trust what I see, I won't change my mind until you show the generated queries (and the mapping allowing to fully understand the model).

于 2010-11-03T04:43:55.270 に答える