title: Hibernate @OneToOne References an Unknown Entity Error
body: <p>I'm having a hard time finding the root cause of an error where my @OneToOne mapping isn't working and is returning a "references an unknown entity" exception. </p>
  
  <p>To start with I ensured that both classes are properly annotated with the @Entity tag. Also it is worth noting my Product.java class (which you will see below) worked fine and only encounters a problem when I try to attach a foreign key to my Project.java class referencing the Product.java class.</p>
  
  <p>Java Code for Project.java and Product.java</p>
  
  <pre><code>@Entity
  @Table (name="project")
  @SequenceGenerator(name="seq_project",sequenceName="BI**********.SEQ_PROJECT", allocationSize=1, initialValue=1)
  public class Project {
  
      //Fields
      @Id
      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_project")
      @Column(name="PROJECT_ID")
      private int id;
      @Column(name="PROJECT_CODE")
      private String projectCode;
      @Column(name="PRODUCT_ID")
      private int productId;
      @Column(name="DESCRIPTION")
      private String description;
  
      @OneToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
      //@PrimaryKeyJoinColumn
      @JoinColumn(name="PRODUCT.PRODUCT_ID")
      private Product product;
  
  
  @Entity
  @Table (name="PRODUCT")
  @SequenceGenerator(name="seq_product",sequenceName="BI************.SEQ_PRODUCT", allocationSize=1, initialValue=1)
  public class Product {
  
      //Fields
      @Id
      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_product")
      @Column(name="PRODUCT_ID")
      private int productId;
      @Column(name="PRODUCT_NAME")
      private String productName;
      @Column(name="DESCRIPTION")
      private String description;
      @OneToOne(mappedBy="Project")
      @JoinColumn(name="PROJET_FK1")
      private Project project;
  </code></pre>
  
  <p>Here is the error code I'm getting:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.manh.entries.Project.product references an unknown entity: com.manh.entries.Product
  </code></pre>
  
  <p>Thanks for any help and advice. </p>