开发者

hibernate resultset and mapping confusion

I was having a problem in getting result through hibernate.

I have four tables SnsUser, Participant, Interaction, Content; SnsUser & Interaction has many-2-many relationsh开发者_JAVA百科ip and Interaction and Content has many-2-one. (SnsUser and Interation got Set of Participant in there mapping classes, hibernate does for many-2-many)

when I run HQL like

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

(returning List(SnsUser) list)

it gives me let say 10 rows and in each row (i.e. SnsUser) has 10 rows as Participant.

But when i run like a HQL like

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

it gives me 10 rows and i can get the relevant SnsUser from it. BUT when i look at the actual sql query it is same for the both. Why it behaves like this... ?

answers would be appreciated. al


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜