Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate in Acion- Page-269- Understanding the implicit join-

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
book says-
You might have noticed that there is a world of difference between the following
queries:
from Bid b where b.item.id = 1
from Bid b where b.item.description like '%gc'
The second query uses an implicit table join; the first has no joins at all.


But as far as i can say, both queries are using the implicit table join.

Can you please shed light on it?
 
tabiul mahmood
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The relationship between the Bid and Item table is through a foreign key Item_Id I presume

In the first query there is no need to join as the item.id is already available in the bid table due to the FK relationship
In the second query the Bid and Item table must be joined as the where condition contains "description" which is only available in the item table

Hope this make things clear
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Taibul- very nice- got it

In the first query there is no need to join as the item.id is already available in the bid table due to the FK relationship
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic