title: Foreign key references primary key in spring boot
body: <ol>
  <li><p>I working on adding MCQ question, options and Answer.</p></li>
  <li><p>There are three tables <code>Question</code>, <code>Option</code> and <code>Answer</code>.</p></li>
  </ol>
  
  <p>Below is my database schema </p>
  
  <ol>
  <li><p>questionId (Question table) is primary key referred to by questionId (Option table) is foreign key.</p></li>
  <li><p>questionId (Question table) is primary key referred to by questionId (Answer Table) is foreign key.</p></li>
  <li><p>optionId (Option table) is primary key referred to by optionId (Answer table) is foreign key.</p></li>
  </ol>
  
  <p>I am not able to link primary and foreign key - please help me improve.</p>
  
  <p>QUESTION table:</p>
  
  <pre><code>@Entity
  @Table(name = "mcq_question")
  public class Question {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @JoinColumn (name = "questionId")
  private Long questionId;
  
  @Column(nullable = false)
  private String question;
  
  @OneToOne(fetch = FetchType.LAZY)
  @JoinTable( name = "Answer", joinColumns = @JoinColumn ( name = "question_id"), inverseJoinColumns = @JoinColumn( name = "option_id"))
  private List &lt;Option&gt; options;
  
  @OneToMany(mappedBy = "questionId", cascade = CascadeType.ALL)
  private Set&lt;Option&gt; option;
  
  public Question() { }
  
  public Long getMcqId() {
      return questionId;
  }
  
  public void setMcqId(Long mcqId) {
      this.questionId = mcqId;
  }
  
  public String getQuestion() {
      return question;
  }
  
  public void setQuestion(String question) {
      this.question = question;
  }
  
  @Override
  public String toString() {
      return "SessionMcqModel{" +
              "mcqId=" + questionId +
              ", question='" + question + '\'' +
              '}';
  }
  
  @Override
  public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Question question1 = (Question) o;
      return questionId.equals(question1.questionId) &amp;&amp;
              question.equals(question1.question) &amp;&amp;
              options.equals(question1.options) &amp;&amp;
              option.equals(question1.option);
  }
  
  @Override
  public int hashCode() {
      return Objects.hash(questionId, question, options, option);
  }
  }
  </code></pre>
  
  <p>ANSWER TABLE:</p>
  
  <pre><code>@Entity
  @Table(name = "mcq_Options")
  public class Option {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "option_id")
  private int optionId;
  
  private String option;
  
  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn
  private Question questionId;
  
  public Option() { }
  
  public Option(String option, Question questionId) {
      this.option = option;
  }
  
  public int getOptionId() {
      return optionId;
  }
  
  public void setOptionId(int optionId) {
      this.optionId = optionId;
  }
  
  public String getOption() {
      return option;
  }
  
  public void setOption(String option) {
      this.option = option;
  }
  
  public Question getQuestionId() {
      return questionId;
  }
  
  public void setQuestionId(Question questionId) {
      this.questionId = questionId;
  }
  
  @Override
  public String toString() {
      return "Option{" +
              "optionId=" + optionId +
              ", option='" + option + '\'' +
              ", questionId=" + questionId +
              '}';
  }
  }
  </code></pre>
  
  <p>ERROR:</p>
  
  <p>Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.bluepi.TrainingProject.model.Question.options references an unknown entity: java.util.List</p>