title: How can I use fetch join with @OneToOne relationship?
body: <p>I have entities Post, PostDetail.
  Those are in one to one relationship, and PostDetail is optional.</p>
  
  <pre><code>class Post {
      @Id
      private int id;
  
      @Column
      private String title;
  
      @Column
      private Strint contents;
  
      @OneToOne(cascade = CascadeType.ALL)
      @PrimaryKeyJoinColumn
      private PostDetail postDetail;
  }
  
  class PostDetail {
      @Id
      private int id;
  
      @Column
      private boolean duplicated;
  
      @OneToOne
      private Post post;
  }
  
  public interface PostRepository extends JpaRepository&lt;Post, Integer&gt; {
      @Transactional
      @Query("SELECT a FROM Post a LEFT JOIN FETCH a.postDetail")
      public Page&lt;Post&gt; getAll(Example&lt;Post&gt; example, Pageable pageable);
  
      @Transactional
      @Query("SELECT a FROM Post a LEFT JOIN FETCH a.postDetail")
      public List&lt;Post&gt; getAll();
  }
  </code></pre>
  
  <p>When application is booting up, exception occurs.</p>
  
  <blockquote>
    <p>Caused by: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list ...</p>
  </blockquote>
  
  <p>What is the problem? I'm trying this to avoid N+1 problem when querying post list (getAll()).</p>
  
  <hr>
  
  <p>Sorry, I modified my question.</p>
  
  <p>Both of two PostRepository's methods make errors.</p>
  
  <p>first getAll() throws error "query specified join fetching ..."</p>
  
  <p>second getAll() throws error</p>
  
  <blockquote>
    <p>org.mariadb.jdbc.internal.common.QueryException: Unknown column 'postdetail1_.post_id' in 'field list'</p>
  </blockquote>