| Author |
fetching.lazy
|
Vinoth kumar Gajapathy
Greenhorn
Joined: Oct 05, 2007
Posts: 16
|
|
|
i am new to hibernate can any one tell me why we using fetching.lazy in database coding side(on onetomany,etc) and what is purpose of this and is any other type ? explain please
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
There is both eager and lazy fetching. Basically, an object can be associated with many other objects. At runtime, you may not need to know about all of the associated objects. Say you have a User with ten addresses. If you want to know the user's name, should you do all the database calls to get the 10 addresses as well? Definitely NOT. So, we make associations lazy, and as such, associated classes do not get populated with real data until that real data is needed. It's very efficient, and often very preferrable. I also believe it is the default with all but one-to-one associations. -Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
 |
|
|
subject: fetching.lazy
|
|
|