title: No property .. found for type .. in spring boot
body: <p>I'm a beginner with spring and I have this little issue. &quot;No property questionId found for type CourseTestCompleteField!&quot; I have 2 model classes that are connected via a one to one join.
  That 2 model class are:</p>
  <pre><code>package com.example.springboot.models;
  
  import javax.persistence.*;
  import javax.validation.constraints.NotBlank;
  
  @Entity
  @Table(name = &quot;questions&quot;)
  public class CourseTestQuestion {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name=&quot;question_id&quot;)
      private Long id;
  
      @NotBlank
      @Column(name = &quot;question_course&quot;)
      private String questionCourse;
  
      @NotBlank
      @Column(name = &quot;question_type&quot;)
      private String questionType;
  
      public CourseTestQuestion(){
  
      }
  
      public CourseTestQuestion(String questionCourse, String questionType) {
          this.questionCourse = questionCourse;
          this.questionType = questionType;
      }
  
      // public getters and setters for all fields here
  }
  </code></pre>
  <p>And:</p>
  <pre><code> package com.example.springboot.models;
  
  import javax.persistence.*;
  import javax.validation.constraints.NotBlank;
  
  
  @Entity
  @Table(name = &quot;quiz_complete_field_questions&quot;,
          uniqueConstraints = {
                  @UniqueConstraint(columnNames = &quot;question_id&quot;)
          }
  )
  public class CourseTestCompleteField {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotBlank
      @Column(name = &quot;question_content&quot;)
      private String questionContent;
  
      @NotBlank
      @Column(name = &quot;answer&quot;)
      private String answer;
  
      @NotBlank
      @Column(name = &quot;points&quot;)
      private String points;
  
      @NotBlank
      @Column(name = &quot;course&quot;)
      private String course;
  
      @NotBlank
      @Column(name = &quot;teacher_username&quot;)
      private String teacher;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = &quot;question_id&quot;, referencedColumnName = &quot;question_id&quot;)
      private CourseTestQuestion courseTestQuestion;
  
      public CourseTestCompleteField(){
  
      }
  
      public CourseTestCompleteField(CourseTestQuestion courseTestQuestion, String question, String answer, String points, String course, String teacher) {
          this.courseTestQuestion = courseTestQuestion;
          this.questionContent = question;
          this.answer = answer;
          this.points = points;
          this.course = course;
          this.teacher = teacher;
      }
  
              
      // public getters and setters for all fields here
  }
  </code></pre>
  <p>My repo for both:</p>
  <pre><code>    package com.example.springboot.repository;
  
  import com.example.springboot.models.Course;
  import com.example.springboot.models.CourseTestQuestion;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  import java.util.Optional;
  
  @Repository
  public interface CourseTestQuestionRepository extends JpaRepository&lt;CourseTestQuestion, Long&gt; {
  
      Optional&lt;CourseTestQuestion&gt; findById(Long id);
  
      Optional&lt;CourseTestQuestion&gt; findByQuestionCourse(String questionCourse);
  }
  </code></pre>
  <p>And:</p>
  <pre><code> package com.example.springboot.repository;
  
  
  import com.example.springboot.models.CourseTestCompleteField;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  import java.util.List;
  import java.util.Optional;
  
  @Repository
  public interface CourseTestCompleteFieldRepository extends JpaRepository&lt;CourseTestCompleteField, Long&gt; {
  
      Optional&lt;CourseTestCompleteField&gt; findById(Long id);
  
      Optional&lt;CourseTestCompleteField&gt; findByQuestionId(Long questionId);
  
      Optional&lt;CourseTestCompleteField&gt; findByCourse(String course);
  
      List&lt;CourseTestCompleteField&gt; findByQuestionContent(String questionContent);
  
      List&lt;CourseTestCompleteField&gt; findByTeacher(String teacher);
  
      Boolean existsByQuestionContent(String questionContent);
  }
  </code></pre>
  <p>The problem is with <code>Optional&lt;CourseTestCompleteField&gt; findByQuestionId(Long questionId);</code>but I don't get it why, because in database I have the table for CourseTestCompleteFieldModel with question_id column, and in CourseTestCompleteField I have CourseTestQuestion object. Tho, the table for CourseTestCompleteField has a different name, could be this a problem? I should rename the table to course_test_complete_field?</p>
  <p>Can someone help me please? Thank you</p>