Solved

Hibernate fetch layer configuration

Posted on 2009-07-09
3
310 Views
Last Modified: 2012-06-22
HI: In hibernate, If I have a class A which has one to one mapping (bi direction) to Class B. And Class B has one to one mapping (bi direction) to Class C. And Class C has bidirection to Class D ...

Now when I fetch Class A's object. Hibernate will fetch its assocation with Class B. And Class B will fetch its association Class C. ....

My question is to tune this layer parameter. So when I load Class A's object, I donot need Class C object is also loaded. Where is hibnerate configuration file for it?  
0
Comment
Question by:JianJunShen
  • 2
3 Comments
 
LVL 17

Assisted Solution

by:Dejan Pažin
Dejan Pažin earned 500 total points
ID: 24813123

You have to set lazy loading on those properties. If you are using annotations (I recommend it), this is what you do:


@OneToOne(fetch = FetchType.LAZY)

or

@ManyToOne(fetch = FetchType.LAZY)

0
 
LVL 17

Accepted Solution

by:
Dejan Pažin earned 500 total points
ID: 24813208
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24813469
Also google: hibernate proxy object

for some good reading. A proxy is what is created to represent classes in lazy loading, so you should understand them.
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
Python Assistance 7 73
Checkbox and ListView in Android Layout 4 56
thymeleaf natural templating vs JSP 2 67
Java Options in Zimbra Server 2 46
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

910 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

22 Experts available now in Live!

Get 1:1 Help Now