title: @OneToOne Annotation Error : references an unknown entity:
body: <p>I work on learning app, in fact making relationships between two tables.</p>
  <p>User - Base table that can have one primary account
  PrimaryAccount - that is also reference to PrimaryTransactions with OnetoMany annotation,
  PrimaryTransaction - has reference to PrimaryAccount as many transaction related to primary Account.</p>
  <p>Although (as per my perception) I'm mentioning right reference between both class but getting an error as follows. Perhaps error lies because of PrimaryAccount.java doesn't have reference for User.java whereas User.java does have for PrimaryAccount.java.
  I wonder that the instructor I follow successful runing his app in this way.
  Any help will be appreciated.</p>
  <p>Error:</p>
  <pre><code> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
   'entityManagerFactory' defined in class path resource 
   [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation 
   of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or 
   @ManyToOne on com.userfront.domain.PrimaryTransaction.primaryAccount references an unknown 
   entity: com.userfront.domain.PrimaryAccount
                     
  </code></pre>
  <p>PrimaryAccount.java</p>
  <pre><code>package com.userfront.domain;
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import javax.persistence.*;
  import java.math.BigDecimal;
  import java.util.List;
  
  public class PrimaryAccount {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  private int accountNumber;
  private BigDecimal accountBalance;
  
  @OneToMany(mappedBy = &quot;primaryAccount&quot;, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  @JsonIgnore
  private List&lt;PrimaryTransaction&gt; primaryTransactionList;
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  
  public int getAccountNumber() {
      return accountNumber;
  }
  
  public void setAccountNumber(int accountNumber) {
      this.accountNumber = accountNumber;
  }
  
  public BigDecimal getAccountBalance() {
      return accountBalance;
  }
  
  public void setAccountBalance(BigDecimal accountBalance) {
      this.accountBalance = accountBalance;
  }
  
  public List&lt;PrimaryTransaction&gt; getPrimaryTransactionList() {
      return primaryTransactionList;
  }
  
  public void setPrimaryTransactionList(List&lt;PrimaryTransaction&gt; primaryTransactionList) {
      this.primaryTransactionList = primaryTransactionList;
  }
  </code></pre>
  <p>}</p>
  <p>PrimaryTransaction.java</p>
  <pre><code>package com.userfront.domain;
  import javax.persistence.*;
  import java.math.BigDecimal;
  import java.util.Date;
  
  @Entity
  public class PrimaryTransaction {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  private Date date;
  private String description;
  private double amount;
  
  
  public PrimaryTransaction() {
  }
  
  public PrimaryTransaction(Date date, String description, String type, String status, double amount, BigDecimal availableBalance, PrimaryAccount primaryAccount) {
      this.date = date;
      this.description = description;
      this.amount = amount;
      this.primaryAccount = primaryAccount;
  }
  
  @ManyToOne
  @JoinColumn(name = &quot;primary_account_id&quot;)
  private PrimaryAccount primaryAccount;
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  
  public Date getDate() {
      return date;
  }
  
  public void setDate(Date date) {
      this.date = date;
  }
  
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  
  
  
  public double getAmount() {
      return amount;
  }
  
  public void setAmount(double amount) {
      this.amount = amount;
  }
  
  public PrimaryAccount getPrimaryAccount() {
      return primaryAccount;
  }
  
  public void setPrimaryAccount(PrimaryAccount primaryAccount) {
      this.primaryAccount = primaryAccount;
  }
  }
  </code></pre>
  <p>User.java</p>
  <pre><code>package com.userfront.domain;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import javax.persistence.*;
  import java.util.List;
  
  @Entity
  public class User {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;userId&quot;, nullable = false, updatable = false)
  private Long userId;
  private String username;
  private String password;
  private String firstName;
  private String lastName;
  @Column(name = &quot;email&quot;, nullable = false, updatable = false)
  private String email;
  private String phone;
  
  private boolean enable = true;
  
  @OneToOne
  private PrimaryAccount primaryAccount;
  
  
  public Long getUserId() {
      return userId;
  }
  
  public void setUserId(Long userId) {
      this.userId = userId;
  }
  
  public String getUsername() {
      return username;
  }
  
  public void setUsername(String username) {
      this.username = username;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public String getFirstName() {
      return firstName;
  }
  
  public void setFirstName(String firstName) {
      this.firstName = firstName;
  }
  
  public String getLastName() {
      return lastName;
  }
  
  public void setLastName(String lastName) {
      this.lastName = lastName;
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getPhone() {
      return phone;
  }
  
  public void setPhone(String phone) {
      this.phone = phone;
  }
  
  public boolean isEnable() {
      return enable;
  }
  
  public void setEnable(boolean enable) {
      this.enable = enable;
  }
  
  public PrimaryAccount getPrimaryAccount() {
      return primaryAccount;
  }
  
  public void setPrimaryAccount(PrimaryAccount primaryAccount) {
      this.primaryAccount = primaryAccount;
  }
  
  
  
  @Override
  public String toString() {
      return &quot;User{&quot; +
              &quot;userId=&quot; + userId +
              &quot;, username='&quot; + username + '\'' +
              &quot;, password='&quot; + password + '\'' +
              &quot;, firstName='&quot; + firstName + '\'' +
              &quot;, lastName='&quot; + lastName + '\'' +
              &quot;, email='&quot; + email + '\'' +
              &quot;, phone='&quot; + phone + '\'' +
              &quot;, enable=&quot; + enable +
              &quot;, primaryAccount=&quot; + primaryAccount +
              '}';
      }
     }
  </code></pre>