Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/MOXy/JPA/CompoundPrimaryKeys"

< EclipseLink‎ | Examples‎ | MOXy‎ | JPA
(New page: <source lang="java"> @Entity public class PhoneNumber { @ManyToOne @JoinColumns({ @JoinColumn(name="E_ID", referencedColumnName = "E_ID"), @JoinColumn(name="E_COUN...)
 
Line 16: Line 16:
 
<source lang="java">
 
<source lang="java">
 
@Entity
 
@Entity
 +
@IdClass(EmployeeId.class)
 
public class Employee {
 
public class Employee {
  
Line 30: Line 31:
 
     @XmlInverseReference(mappedBy="contact")
 
     @XmlInverseReference(mappedBy="contact")
 
     private List<PhoneNumber> contactNumber;
 
     private List<PhoneNumber> contactNumber;
 +
 +
}
 +
</source>
 +
 +
<source lang="java">
 +
@Entity
 +
public class EmployeeId {
 +
 +
    private BigDecimal eId;
 +
    private String country;
  
 
}
 
}
 
</source>
 
</source>

Revision as of 11:55, 1 December 2009

@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 {
 
    @Id
    @Column(name="E_ID")
    @XmlID
    private BigDecimal eId;
 
    @Id
    @XmlID
    private String country;
 
    @OneToMany(mappedBy="contact")
    @XmlInverseReference(mappedBy="contact")
    private List<PhoneNumber> contactNumber;
 
}
@Entity
public class EmployeeId {
 
    private BigDecimal eId;
    private String country;
 
}

Back to the top