Solved

why  fetch join in hibernate

Posted on 2009-05-11
2
521 Views
Last Modified: 2013-11-24
please see this hibernate tutorial. i have question here

http://72.14.235.132/search?q=cache:Va2qJokS5gwJ:www.metaarchit.com/hibernate_tutorials/Hibernate%2520Tutorial%252004.pdf+Hibernate+Association&cd=9&hl=en&ct=clnk&gl=in&client=firefox-a


see this code given in that tutorial  under   "1.2 Fetching strategies"

<hibernate-mapping package="com.metaarchit.bookshop">
<class name="Book" table="BOOK">
...
<many-to-one name="publisher" class="Publisher" column="PUBLISHER_ID"
lazy="false" fetch="join" />
</class>
</hibernate-mapping>


My Question is , why do we use fetch="join"  in the above ?  if we just  have lazy="false"  then book and chapters both will be loaded .....so why  extra fetch="join"  again ?   i think we can skip fetch="join"  .....i am not clear at this part.
0
Comment
Question by:cofactor
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 24360679
you would do that to avoid the second select, and select the related publisher using a join


0
 

Author Comment

by:cofactor
ID: 24360809
Ahh...so   this is just a performance issue here ...earlier two select query fired ...now single select query will be fired because of this "join"  thingie  ...good to know ...thanks


thanks


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
listing all functions in JavaScript 19 178
Java JRE greater than 1.6 5 50
why cannot we forward request once the response is committed 2 33
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now