users@glassfish.java.net

OneToMany association in an Embedded class not being fetched

From: <glassfish_at_javadesktop.org>
Date: Tue, 15 May 2007 03:15:26 PDT

I have a OneToMany association defined in an Embedded class as in the following example:
[code]
@Entity
public class Employer {
    
    @Embedded
    public Employer.Employees employees;

    @Embeddable
    public static class Employees{
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "employerId")
        public List<Employee> employees;
    }
}

@Entity
public class Employee {
}
[/code]
When loading an Employer instance with the EntityManager
[code]
Employer employer = (Employer)em.find(Employer.class, 1);
[/code]
the associated Employee objects cannot be accessed - the [b]employer.employees[/b] wrapper object for the employee list is null.

I'm using glassfish v1 ur1. Is this a (known) bug in Toplink or do I have to take some additional steps to have the embedded object instantiated and the employee list fetched (eagerly or lazily) ? (The inner static class presence comes from the class being generated by JAXB from a xml schema).
[Message sent by forum member 'kolmis' (kolmis)]

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