Rajendra Prakash wrote:Lazy fetch : lazy=true means not to load child objects while loading parent objects. can you example code for lazy fetching.
One important thing to note is that you cannot use "lazy=true" if you plan to send your entity objects outside of the context of the Hibernate Session object because your entity object keeps a reference to the session. For example, if you load the parent entity in a Session
EJB and pass the parent entity to a servlet and then call the getChildren() method that is marked as "lazy=true" an exception will be throw due to an invalid session. The exception will be thrown even if you make a call to the method before passing the parent entity to the servlet. Therefore, with some well thought out exceptions, if you are working within an EJB enviornment it is best to define all parent-child relations as "lazy=false".
Ran