I am trying to create pojo's. My requirement is to retrieve user information based on policy id. Each customer has only one address and one policy.

So I have created three POJO's. Address.java, Customer.java, Policy.java.

Address.java

```
@Entity
@Table(name="CUSTOMER_ADDRESS")
public class Address {

    @Column(name="ADDRESS_STREET")
    private String address_street;

    @Column(name="ADDRESS_CITY")
    private String address_city;

    @Column(name="ADDRESS_STATE")
    private String address_state;

    @Column(name="ADDRESS_ZIPCODE")
    private String address_zipcode;

    @GenericGenerator(name = "generator", strategy = "foreign",
    parameters = @Parameter(name = "property", value = "CUSTOMER"))
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name="CUSTOMER_ID")
    private int customer_id;
    public String getAddress_street() {
        return address_street;
    }
    public void setAddress_street(String address_street) {
        this.address_street = address_street;
    }
    public String getAddress_city() {
        return address_city;
    }
    public void setAddress_city(String address_city) {
        this.address_city = address_city;
    }
    public String getAddress_state() {
        return address_state;
    }
    public void setAddress_state(String address_state) {
        this.address_state = address_state;
    }
    public String getAddress_zipcode() {
        return address_zipcode;
    }
    public void setAddress_zipcode(String address_zipcode) {
        this.address_zipcode = address_zipcode;
    }
    public int getCustomer_id() {
        return customer_id;
    }
    public void setCustomer_id(int customer_id) {
        this.customer_id = customer_id;
    }

}

```

Customer.java

```
@Entity
@Table(name="CUSTOMER")
public class Customer {

    private int customer_id;
    private String customer_name;
    private Date customer_dob;
    private Address address;
    private Policy policy;

    @OneToOne
    @JoinColumn(name = "CUSTOMER_ID")
    public Address getAddress() {
        return address;
    }
    public void setAddress(Address address) {
        this.address = address;
    }
    @OneToOne
    @JoinColumn(name = "CUSTOMER_ID")
    public Policy getPolicy() {
        return policy;
    }
    public void setPolicy(Policy policy) {
        this.policy = policy;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "CUSTOMER_ID")
    public int getCustomer_id() {
        return customer_id;
    }
    public void setCustomer_id(int customer_id) {
        this.customer_id = customer_id;
    }

    @Column(name = "CUSTOMER_NAME")
    public String getCustomer_name() {
        return customer_name;
    }
    public void setCustomer_name(String customer_name) {
        this.customer_name = customer_name;
    }

    @Column(name = "CUSTOMER_DOB")
    public Date getCustomer_dob() {
        return customer_dob;
    }
    public void setCustomer_dob(Date customer_dob) {
        this.customer_dob = customer_dob;
    }

}

```

Policy.java

```
@Entity
@Table(name="CUSTOMER_POLICY_DETAILS")
public class Policy implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="POLICY_ID")
    int policy_id;

    @Column(name="POLICY_START_DATE")
    String policyStartDate;

    @Column(name="POLICY_END_DATE")
    String policyEndDate;

    @GenericGenerator(name = "generator", strategy = "foreign",
    parameters = @Parameter(name = "property", value = "CUSTOMER"))
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name="CUSTOMER_ID")
    int customer_id;

    public int getCustomer_id() {
        return customer_id;
    }

    public void setCustomer_id(int customer_id) {
        this.customer_id = customer_id;
    }

    public Policy() {
        super();
    }

    public int getPolicy_id() {
        return policy_id;
    }

    public void setPolicy_id(int policy_id) {
        this.policy_id = policy_id;
    }

    public String getPolicyStartDate() {
        return policyStartDate;
    }

    public void setPolicyStartDate(String policyStartDate) {
        this.policyStartDate = policyStartDate;
    }

    public String getPolicyEndDate() {
        return policyEndDate;
    }

    public void setPolicyEndDate(String policyEndDate) {
        this.policyEndDate = policyEndDate;
    }

}

```

Should I include the Address object and Policy object in my Customer class?
Since I have the customer\_id attribute in the Address and Policy class, do I not need to include it in my Customer class?