Solved

why  fetch join in hibernate

Posted on 2009-05-11
2
520 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 77
json example 39 111
groovy example issue 10 66
Java JRE greater than 1.6 5 19
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 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

18 Experts available now in Live!

Get 1:1 Help Now