title: Hibernate @OneToMany without a separate join table
body: <p>Consider the following database schema:</p>
  
  <pre><code>create table UserGroup ( id int not null auto_increment, name varchar(200),
      primary key(id));
  create table User ( id int not null auto_increment, name varchar(200),
      groupId int not null, primary key(id));
  </code></pre>
  
  <p>User.groupId = UserGroup.id, so a user can only be a member of one group, but a usergroup can exist of many users. Fine so far, let's make the entities in Hibernate.  Here's <code>User</code>:</p>
  
  <pre><code>@Entity
  @Table(name = "User")
  public class User {
  
      @Id
      @Column(name="id", nullable = false)
      private Integer id;
  
      @Column(name="name", length = 200, nullable = true)
      private String name;
  
      @ManyToOne(fetch=FetchType.EAGER)
      @JoinColumn(name = "groupId", nullable = false, insertable=false, updatable=false)
      @ForeignKey(name="FK_GroupId")
      private UserGroup userGroup;
  
      /* Getters, Setters, toString, equals &amp; hashCode */
  }
  </code></pre>
  
  <p>Here's <code>UserGroup</code>:</p>
  
  <pre><code>@Entity
  @Table(name = "UserGroup")
  public class UserGroup {
  
      @Id
      @Column(name="id", nullable = false)
      private Integer id;
  
      @Column(name="name", length = 200, nullable = true)
      private String name;
  
      @OneToMany(fetch=FetchType.EAGER)
      private List&lt;User&gt; users;
  
      /* Getters, Setters, toString, equals &amp; hashCode */
  }
  </code></pre>
  
  <p>Now I'll get an error <code>"Table mydb.usergroup_user' doesn't exist"</code> because it expects a join-table. My data structure is "set in stone" due to interoperability with other applications that this application will replace, so I won't be making a join-table. Also, it should not be needed. How can I make a <code>List&lt;User&gt; users</code> that simply is a list of User where <code>User.groupId == UserGroup.Id</code>?</p>