-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Lazy Loading
PostPosted: Thu May 14, 2009 3:18 am 
Newbie

Joined: Sat May 09, 2009 2:03 am
Posts: 14
how we can enable lazy loading in hibernate other then using lazy="true".
is there any other way also??


thanks.


Top
 Profile  
 
 Post subject: Re: Lazy Loading
PostPosted: Thu May 14, 2009 4:09 am 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi, the default behaviour from Hibernate is that only
@OneToMany and @ManyToMany are fechted lazy.

@Basic, @Lob and @OneToOne are fetched eager by default.
For @Lob you can activate lazy loading only with bytecode instrumentation (See chapter 19.1.7 of the manual -- the rest of chapter 19 is also useful). It's not recommended and a special query is the preferred solution.

So you normally don't have to change anything, if that is ok for you.

Why don't you like
Quote:
lazy="true"
? Have you tried annotations?

E. g.
Code:
  @OneToMany(fetch = FetchType.EAGER, cascade = javax.persistence.CascadeType.ALL)

or
Code:
@OneToMany(fetch = FetchType.LAZY, cascade = javax.persistence.CascadeType.ALL)


Greetings Michael


Top
 Profile  
 
 Post subject: Re: Lazy Loading
PostPosted: Thu May 14, 2009 5:14 am 
Newbie

Joined: Sat May 09, 2009 2:03 am
Posts: 14
Thanks Michael for replying,
actually i was asked this ques in an interview..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.