All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.gentity.test.test5a_element_collection_embeddable.Person Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version

package com.github.gentity.test.test5a_element_collection_embeddable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "PERSON")
public class Person implements Serializable
{

    @ElementCollection
    @CollectionTable(name = "PHONE_NUMBER", joinColumns = {
        @JoinColumn(name = "PERSON_ID", referencedColumnName = "ID")
    })
    protected List phoneNumber = new ArrayList();
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    protected Integer id;
    @Column(name = "FIRST_NAME", length = 100, nullable = false)
    protected String firstName;
    @Column(name = "LAST_NAME", length = 100, nullable = false)
    protected String lastName;

    public static Person.Builder builder() {
        return new Person.Builder();
    }

    public List getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(List phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public Integer getId() {
        return id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public static class Builder {

        private final Person instance = new Person();

        public Person build() {
            return instance;
        }

        public Person.Builder phoneNumber(List phoneNumber) {
            instance.phoneNumber = phoneNumber;
            return this;
        }

        public Person.Builder firstName(String firstName) {
            instance.firstName = firstName;
            return this;
        }

        public Person.Builder lastName(String lastName) {
            instance.lastName = lastName;
            return this;
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy