Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EJB 3.0 Lazy Loading?

Status
Not open for further replies.

edvedafi

Programmer
May 17, 2003
24
0
0
US
I am wondering if it is possilbe to force an object that is set to lazy load to load after it has been detached. Basically what we have is Object A has an instance of Object B. In a some clients we want B, but in most we don't. I would like to be able to set A to lazy load B, but the problem is the client that wants B does not have a connection to the database. So we would like to return A through a DAO then have another method in the DAO that can force A to load B. Here's an example, what I can't figure out is what should be inside the fullyLoadedA method.
Code:
A.java
CODE
@Entity
public class A {
...
 private B myB;

 @OneToOne
 public B getMyB() {
  return myB;
 }
...
}
Code:
B.java
CODE
@Entity
public class B
...
}
Code:
ADAO.java
CODE
public class ADAO {
...
 //this should use lazy loading
 public A findById(Aid id){ ... }

 //at some point call this to load
 public A fullyLoadedA(A a){
    //somehow force A to load all of its lazy objects and return it?
 }
...
}
Thanks for all advice

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top