users@glassfish.java.net

How to "instantiate the LAZY relationship prior to serialization"

From: <glassfish_at_javadesktop.org>
Date: Tue, 21 Aug 2007 10:08:55 PDT

Hi,

I am trying to get list of objects as follows

...
            Manager manager = sessionEJB.getManagerById(new Long(1));
            List<Employee> employees = manager.getEmployeeList();
            for (Employee e:employees) {
                System.out.println(e.getEname());
            }
...

It seems that it is not correct the way I do it.

Because it is giving me the following exception

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.
        at oracle.toplink.essentials.exceptions.ValidationException.instantiatingValueholderWithNullSession(ValidationException.java:872)
        at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:218)
        at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
        at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:193)
        at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:315)
        at oracle.toplink.essentials.indirection.IndirectList$1.<init>(IndirectList.java:410)
        at oracle.toplink.essentials.indirection.IndirectList.iterator(IndirectList.java:409)
        at lazyloading.SessionEJBClient.main(SessionEJBClient.java:20)

I would appreciate for any help.

Mustafa
[Message sent by forum member 'mcayci' (mcayci)]

http://forums.java.net/jive/thread.jspa?messageID=231845