Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Lazy relationship

515957Oct 16 2006 — edited Apr 1 2010
Hi to everebody,
I have problem with Lazy relationship between two entities I generated from HR tables: Departments and Employees.
For one Department there are many Employee(s), and one Employee belongs to exactly one Department.
I wrote EJB client:
final Context context = getInitialContext();
SessionEJB sessionEJB = (SessionEJB)context.lookup("SessionEJB");
Department dept = sessionEJB.getDepartmentById(new Long(40));
System.out.println(dept.getDepartmentName()); // OK
List<Employee> employees = dept.getEmployeeList(); // ERROR
System.out.println(employees.size());

Client failed to execute on last two lines, and exception log is:

Local Exception Stack:
Exception [TOPLINK-7242] (Oracle TopLink Essentials - 2006.7 (Build 060720)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.

Does anybody know how to instantiate Lazy relationship?
Thanks,Almir
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2010
Added on Oct 16 2006
12 comments
15,731 views