title: How to map multiple columns of one table to single parent column of another table using Spring JPA using Hibernate`
body: <p>I want to map 3 columns of address (country, state,city) to the configuration table id column.</p>
  
  <p>I have the following table structure:</p>
  
  <p><strong>Address Model/table</strong></p>
  
  <pre><code>import java.util.Date;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.OneToOne;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "addresses")
  public class Address {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long id;
  
      private Configuration configuration;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "id")
      private int country;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "id")
      private int state;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "id")
      private int city;
  
      private int zipCode;
  
      @Column(name = "created_at")
      private Date createdAt;
      @Column(name = "created_by")
      private String createdBy;
  
      @Column(name = "updated_at")
      private Date updatedAt;
  
      @Column(name = "updated_by")
      private String updatedBy;
  
      private String status;
      private String deleteFlag;
  }
  </code></pre>
  
  <p><strong>Configuration Model/Table</strong></p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import javax.validation.constraints.NotNull;
  
  @Entity
  @Table(name = "configurations")
  public class Configuration {
  
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       private long id;
  
       @NotNull
       private String configurationName;
  
       @NotNull
       private String configurationType;
  
       @NotNull
       private String ConfigurationDescription;
  
       @Column(name = "parent_id")
       private long parentId;
  }
  </code></pre>
  
  <p>Here, i am unable to map the relationship between Configuration and Address and Configuration with itself.</p>
  
  <p>Please friends help me in this regards.</p>
  
  <p><strong>Updated</strong></p>
  
  <pre><code>**Configurations Table record**
  
  id configname  configtype  configdescription parentid created_at  updated_at Status deleteflag
  1  India       Country     This is a country  0       12-05-2016  Null Active Null
  2  Delhi       State       This is a State    1       12-05-2016  Null Active Null
  3  New Delhi   City        This is a city     2       12-05-2016  Null Active Null
  ----------
  
  **Address Table record**
  
  id Country State City zipcode created_at updated_at status deleteflag
  1      1     2     3  110034  12-05-2016  Null       Active  Null
  </code></pre>