title: Hibernate Many-To-One Relationship without Primary Key or Join Table
body: <h2>Problem</h2>
  
  <p>I would like to start by saying that I realize the database structure is atrocious, but I cannot change it at this point in time.</p>
  
  <p>That being said, I have the need to create a one-to-many, bi-directional relationship in Hibernate (4.2.1) which involves no primary keys (only a unique key on the "parent" side of the relationship) and no join tables.  The foreign key representing this relationship is a backpointer from the "child" to the "parent" (see below).  I have searched and tried various different annotation configurations with no luck.  Is what I'm asking for possible?</p>
  
  <h2>Database</h2>
  
  <p><strong>GLOBAL_PART</strong></p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE "GLOBAL_PART" (    
      "GLOBAL_PART_ID" NUMBER NOT NULL,
      "RELEASES" NUMBER,
      CONSTRAINT "GLOBAL_PART_PK" PRIMARY KEY ("GLOBAL_PART_ID"),
      CONSTRAINT "GLOBAL_PART_RELEASES_UK" UNIQUE ("RELEASES")
  );
  </code></pre>
  
  <p><strong>PART_RELEASE</strong></p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE "PART_RELEASE" (
      "PART_RELEASE_ID" NUMBER NOT NULL,
      "COLLECTION_ID" NUMBER,
      CONSTRAINT "PART_RELEASE_PK" PRIMARY KEY ("PART_RELEASE_ID"),
      CONSTRAINT "GLOBAL_PART_RELEASE_FK" FOREIGN KEY ("COLLECTION_ID")
          REFERENCES "GLOBAL_PART" ("RELEASES") ON DELETE CASCADE ENABLE
  );
  </code></pre>
  
  <p>Reference:</p>
  
  <pre><code>PART_RELEASE                 GLOBAL_PART
  -------------------          ------------
  PART_RELEASE_ID (PK)         GLOBAL_PART_ID (PK)
  COLLECTION_ID -------------&gt; RELEASES (UK)
  </code></pre>
  
  <h2>Java</h2>
  
  <p><strong>GlobalPart.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "GLOBAL_PART")
  @SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "GLOBAL_PART_SEQ")
  public class GlobalPart extends ModelBase implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "GLOBAL_PART_ID", unique = true, nullable = false)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_GENERATOR")
      private Long globalPartId;
  
      @OneToMany(fetch = FetchType.EAGER)
      @JoinColumn(name = "COLLECTIONGID")
      private Set&lt;PartRelease&gt; releases;
  
      public Long getGlobalPartId() {
          return globalPartId;
      }
  
      public void setGlobalPartId(Long globalPartId) {
          this.globalPartId = globalPartId;
      }
  
      public Set&lt;PartRelease&gt; getReleases() {
          return releases;
      }
  
      public void setReleases(Set&lt;PartRelease&gt; releases) {
          this.releases = releases;
      }
  
  }
  </code></pre>
  
  <p><strong>PartRelease.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "PART_RELEASE")
  @SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "PART_RELEASE_SEQ")
  public class PartRelease extends ModelBase implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "PART_RELEASE_ID", unique = true, nullable = false)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_GENERATOR")
      private String partReleaseId;
  
      @ManyToOne
      @JoinColumn(name = "RELEASES")
      private GlobalPart globalPart;
  
      public String getPartReleaseId() {
          return partReleaseId;
      }
  
      public void setPartReleaseId(String partReleaseId) {
          this.partReleaseId = partReleaseId;
      }
  
      public GlobalPart getGlobalPart() {
          return globalPart;
      }
  
      public void setGlobalPart(GlobalPart globalPart) {
          this.globalPart = globalPart;
      }
  
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated!!</p>