title: Entity as key on a One to One relationship returning "Composite-ID" error
body: <p>I have the following 2 entities:</p>
  
  <pre><code>   @Entity(name = "Employee")
     @Table(name = "EMPLOYEE")
     public class Employee implements Serializable {
        @Id
        @Column(name = "EMP_ID", insertable = true, updatable = false, nullable = false)
        private int id;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity(name = "Draw")
  @Table(name = "DRAW")
  
  public class Draw extends AuditableEntity {
      @Id
      @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
      @JoinColumn(name = "EMP_ID", referencedColumnName = "EMP_ID")
      @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
          org.hibernate.annotations.CascadeType.MERGE})
      private Employee employee = null;
  </code></pre>
  
  <p>Let's just say that's the way they want it modeled. This is a OneToOne relationship as specified. However, when I go to test I get the following error:</p>
  
  <blockquote>
    <p>nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/spring/datasource-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: composite-id class must implement Serializable: com.myprojects.tet.data.entity.Draw</p>
  </blockquote>
  
  <p>Why is the <code>employee</code> key in <code>Draw</code> interpreted as a composite-id? Also how do I fix this error. <a href="https://forum.hibernate.org/viewtopic.php?p=2306165&amp;sid=857145b56a9e06c8fa10aca8199c7312" rel="nofollow">I have read</a> that the entity referenced has to be serializable but also that it needs to implement method <code>equals</code> and <code>hashCode</code> (which I haven't implemented yet). Should implementation of those two fix that error?</p>
  
  <p><strong>Editing for clarity:</strong></p>
  
  <p>I have two modeled tables: <code>EMPLOYEE</code> and <code>DRAW</code>:</p>
  
  <p><code>EMPLOYEE</code> has: integer <code>emp_id</code>, plus a lot of other columns.</p>
  
  <p><code>DRAW</code> has: integer <code>emp_id</code>, integer <code>totalPoints</code>.</p>
  
  <p>The draw table will be populated and purged every certain time, so column <code>totalPoint</code> cannot be in table <code>EMPLOYEE</code>. I am unsure if my entity relations are correct (i.e. having entity <code>employee</code> as the id for <code>draw</code>).</p>