Jump to: navigation, search


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


This example demonstrates how to derive an XML representation from a set of JPA entities using JAXB when a JPA entity has an embedded ID class.

JPA Entities

public class PhoneNumber {
        @JoinColumn(name="E_ID", referencedColumnName = "E_ID"),
        @JoinColumn(name="E_COUNTRY", referencedColumnName = "COUNTRY")
    private Employee contact;
public class Employee {
    private EmployeeId id;
    private List<PhoneNumber> contactNumber;
public class EmployeeId {
    private BigDecimal eId;
    private String country;

JAXB Bindings

For this example the XML acessor type will be set to FIELD for all the model classes. This can be set as a package level JAXB annotation.

package com.example.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;