EclipseLink/Examples/MOXy/JPA/EmbeddedIdClass

From Eclipsepedia

< EclipseLink‎ | Examples‎ | MOXy‎ | JPA
Revision as of 12:06, 1 December 2009 by Blaise.doughan.oracle.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

JPA Entities

@Entity
public class PhoneNumber {
 
    @ManyToOne
    @JoinColumns({
        @JoinColumn(name="E_ID", referencedColumnName = "E_ID"),
        @JoinColumn(name="E_COUNTRY", referencedColumnName = "COUNTRY")
    })
    @XmlIDREF
    private Employee contact;
 
}
@Entity
@IdClass(EmployeeId.class)
public class Employee {
 
    @EmbeddedId
    private EmployeeId id;
 
    @OneToMany(mappedBy="contact")
    @XmlInverseReference(mappedBy="contact")
    private List<PhoneNumber> contactNumber;
 
}
@Embeddable
public class EmployeeId {
 
    @Column(name="E_ID")
    private BigDecimal eId;
 
    private String country;
 
}

JAXB Bindings