Triggering a Getter On BasicCollection Or BasicMap Configured With FetchType.Lazy Returns Not Instantiated IndirectList or IndirectMap (Doc ID 1064928.1)

Last updated on MAY 24, 2011

Applies to:

Oracle TopLink - Version: 11.1.1.0.1 and later   [Release: Oracle11g and later ]
Information in this document applies to any platform.

Symptoms


Triggering getter on BasicCollection or BasicMap configured with FetchType.LAZY returns not instantiated IndirectList or IndirectMap.

e.g.

Entity

@Entity
@Table(name="EMP")
public class Employee {
     @Id
     @Column(name="EMP_ID")
     private int id;
     private String name;

     @BasicCollection (
          //fetch=FetchType.EAGER, //funktioniert
          valueColumn=@Column(name="DESCRIPTION")
     )
     @CollectionTable (
          name="RESPONS",
          primaryKeyJoinColumns=
               {@PrimaryKeyJoinColumn(name="EMPLOYEE_ID",
               referencedColumnName="EMP_ID")}
     )
     private List responsibilities = new ArrayList();
...

Business Logic

List emps =
    (List) em.createQuery("Select e FROM Employee e").getResultList();
    for (Employee emp : emps) {
        System.out.println(emp.toString());
        System.out.println(emp.getResponsibilities());
    }
...


Observation

System.out.println(emp.getResponsibilities());

prints

{IndirectList: not instantiated}

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms