users@glassfish.java.net

Re: OneToMany association in an Embedded class not being fetched

From: <glassfish_at_javadesktop.org>
Date: Tue, 15 May 2007 18:10:22 PDT

Thanks for the response and the specs reference point, actually I had read a similar paragraph in the api docs for Embeddable annotation.

But since the Toplink JPA Annotations document at http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html
states
[i]
Use the @AssociationOverride annotation to customize an @OneToOne or @ManyToOne mapping inherited from a @MappedSuperclass or @Embeddable to change the @JoinColumn associated with the field or property if the inherited column definition is incorrect for your entity (for example, if the inherited column name is incompatible with a pre-existing data model, or invalid as a column name in your database).
[/i]
I had thought I could use associations inside Embeddables.

Actually I managed to get what I needed done by adding a Column annotated property into the inner class
[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;

        @Column(name = "id", insertable=false, updatable=false)
        private Long dummy;
    }
}
[/code]

The current Toplink Essentials manages to instantiate the association list then.

I guess it's a feature request/bug for toplink jpa after all.
[Message sent by forum member 'kolmis' (kolmis)]

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