Solved

Hibernate fetch layer configuration

Posted on 2009-07-09
3
307 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wordcount challenge 11 78
firstChar challenge 13 86
best (free) software to access postgres db (java) 1 19
Unable to start eclipse ? 17 87
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

744 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

12 Experts available now in Live!

Get 1:1 Help Now