title: Mapping of primary key as foreign key to another table
body: <p>I have a problem regarding a foreign key relationship and its JPA counterpart.</p>
  
  <p>In the following tables. <code>means_of_transport</code> is a table with a consecutive numbering. The other tables have less entries with a mapping of their primary key as a foreign key to the primary key of <code>means_of_transport</code>. Sadly, I cannot change the data model.</p>
  
  <p><strong>Table <code>means_of_transport</code></strong></p>
  
  <pre><code>CREATE TABLE means_of_transport (
      id INT PRIMARY KEY NOT NULL,
      max_capacity INT
  );
  </code></pre>
  
  <p><strong>Table <code>ocean_ship</code></strong></p>
  
  <pre><code>CREATE TABLE ocean_ship (
      means_of_transport_id INT PRIMARY KEY NOT NULL,
      name VARCHAR(45) NOT NULL,
      FOREIGN KEY ( means_of_transport_id ) REFERENCES means_of_transport ( id )
  );
  CREATE INDEX fk_ship_means_of_transport1_idx ON ocean_ship ( means_of_transport_id );
  </code></pre>
  
  <p>There are more tables besides <code>ocean_ship</code> with the same key structure but other fields.</p>
  
  <p><strong>MeansOfTransport.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "means_of_transport")
  public class MeansOfTransport extends Model {
      @Id
      public Integer id;
      public Integer maxCapacity;
  }
  </code></pre>
  
  <p><strong>OceanShip.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "ocean_ship")
  public class OceanShip extends Model {
      @Id
      @OneToOne
      @JoinColumn(table = "means_of_transport", referencedColumnName = "id")
      public MeansOfTransport meansOfTransport;
  
      public String name;
  }
  </code></pre>
  
  <p>Now every time I try to use <code>OceanShip</code> in another JPA class as a field, I get this error: <code>Error reading annotations for models.Classname</code>.</p>
  
  <p>Am I missing some annotations?</p>
  
  <p><strong>edit</strong></p>
  
  <p>Example usage:</p>
  
  <pre><code>@ManyToOne
  @Column(name = "ocean_ship")
  public OceanShip oceanShip;
  </code></pre>
  
  <p>Full stack trace:</p>
  
  <pre><code>play.api.UnexpectedException: Unexpected exception[RuntimeException: Error reading annotations for models.ContainerOrder]
          at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:150) ~[play_2.10.jar:2.1.5]
          at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.5]
          at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
          at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:114) ~[play_2.10.jar:2.1.5]
          at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.1.5]
          at scala.util.Either$RightProjection.flatMap(Either.scala:523) ~[scala-library.jar:na]
  Caused by: java.lang.RuntimeException: Error reading annotations for models.ContainerOrder
          at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:54) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1034) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.core.InternalConfiguration.&lt;init&gt;(InternalConfiguration.java:124) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210) ~[avaje-ebeanorm-server.jar:na]
  Caused by: java.lang.NullPointerException: null
          at com.avaje.ebeaninternal.server.deploy.BeanTable.createJoinColumn(BeanTable.java:94) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocOnes.readAssocOne(AnnotationAssocOnes.java:145) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocOnes.parse(AnnotationAssocOnes.java:54) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:45) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1034) ~[avaje-ebeanorm-server.jar:na]
          at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565) ~[avaje-ebeanorm-server.jar:na]
  </code></pre>