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

EclipseLink/UserGuide/MOXy/Relationships/Privately Owned/One-to-One


Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

Elug example icon.png Examples


One-to-One Composite Collection Mapping

With EclipseLink Annotations

Use the @OneToOne annotation:

@Entity
public class Employee {
 
    @OneToOne(mappedBy="resident")
    private Address residence;
 
}

Use the EclipseLink extension @XmlInverseReference to map the back-pointer:

@Entity
public class Address {
 
    @OneToOne
    @JoinColumn(name="E_ID")
    @XmlInverseReference(mappedBy="residence")
    private Employee resident;
 
}

Eclipselink-logo.gif
Version: 2.2.0 DRAFT
Other versions...

Back to the top