| package eclipselink.example.jpamoxy.simple.model; |
| |
| import static javax.persistence.CascadeType.*; |
| |
| import java.io.Serializable; |
| import java.util.HashSet; |
| import java.util.Set; |
| |
| import javax.persistence.CascadeType; |
| import javax.persistence.Column; |
| import javax.persistence.Entity; |
| import javax.persistence.GeneratedValue; |
| import javax.persistence.Id; |
| import javax.persistence.NamedQuery; |
| import javax.persistence.OneToMany; |
| import javax.persistence.OneToOne; |
| import javax.xml.bind.annotation.XmlElement; |
| import javax.xml.bind.annotation.XmlElementWrapper; |
| import javax.xml.bind.annotation.XmlRootElement; |
| |
| |
| /** |
| * The persistent class for the CUSTOMER database table. |
| * |
| */ |
| @Entity |
| @NamedQuery(name = "findCustomerByName", |
| query = "SELECT c " + |
| "FROM Customer c " + |
| "WHERE c.firstName = :firstName AND " + |
| " c.lastName = :lastName") |
| @XmlRootElement |
| public class Customer implements Serializable { |
| private static final long serialVersionUID = 1L; |
| |
| @Id |
| @GeneratedValue |
| private long id; |
| |
| @Column(name="FIRST_NAME") |
| private String firstName; |
| |
| @Column(name="LAST_NAME") |
| private String lastName; |
| |
| //bi-directional one-to-one association to Address |
| @OneToOne(mappedBy="customer", cascade = ALL) |
| private Address address; |
| |
| @XmlElementWrapper(name="phone-numbers") |
| @XmlElement(name="phone-number") |
| //bi-directional many-to-one association to PhoneNumber |
| @OneToMany(mappedBy="customer", cascade = ALL) |
| private Set<PhoneNumber> phoneNumbers = new HashSet<PhoneNumber>(); |
| |
| public Customer() { |
| } |
| |
| public long getId() { |
| return this.id; |
| } |
| |
| public void setId(long id) { |
| this.id = id; |
| } |
| |
| public String getFirstName() { |
| return this.firstName; |
| } |
| |
| public void setFirstName(String firstName) { |
| this.firstName = firstName; |
| } |
| |
| public String getLastName() { |
| return this.lastName; |
| } |
| |
| public void setLastName(String lastName) { |
| this.lastName = lastName; |
| } |
| |
| public Address getAddress() { |
| return this.address; |
| } |
| |
| public void setAddress(Address address) { |
| this.address = address; |
| } |
| |
| public Set<PhoneNumber> getPhoneNumbers() { |
| return this.phoneNumbers; |
| } |
| |
| public void setPhoneNumbers(Set<PhoneNumber> phoneNumbers) { |
| this.phoneNumbers = phoneNumbers; |
| } |
| |
| public void addPhoneNumber(PhoneNumber phoneNumber) { |
| this.phoneNumbers.add(phoneNumber); |
| phoneNumber.setCustomer(this); |
| } |
| } |