0


I was having a problem in getting result through hibernate.
I have four tables SnsUser, Participant, Interaction, Content; SnsUser & Interaction has many-2-many relationship 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

Deam
  • 1,007
  • 2
  • 17
  • 36

1 Answers1

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

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • yea. i should have said similar. the join conditions are same. so the point is that would i always get Set populated when i would run from SnsUser? – Deam Nov 03 '10 at 15:52
  • @user330281: I need the mapping and object model to comment further. – Pascal Thivent Nov 03 '10 at 16:16