title: How to assign an @EntityGraph annotation to Spring Data JPA repository .findAll()
body: <p>Annotating the Spring Data JPA repository method <code>findAll()</code> with <code>@EntityGraph</code>:</p>
  
  <pre><code>import org.springframework.data.jpa.repository.JpaRepository;
  [...]
  
  public interface OptgrpRepository extends JpaRepository&lt;Optgrp&gt; {
  
  @EntityGraph(value = "Optgrp.sysoptions")
  List&lt;Optgrp&gt; findAll();
  </code></pre>
  
  <p>}</p>
  
  <p>leads to this error message:</p>
  
  <p><code>org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type Optgrp!</code></p>
  
  <p>Same error happens when changing <code>findAll()</code> to other names:</p>
  
  <p><code>findAllWithDetail()</code> --> <code>No property findAllWithDetail found for type Optgrp!</code></p>
  
  <p><code>findWithDetailAll()</code> --> <code>No property findWithDetailAll found for type Optgrp!</code></p>
  
  <p>Question: Is it at all possible to use the <code>@EntityGraph</code> annotation on a Spring Data JPA repository method that finds all entities?</p>
  
  <p>EDIT: as asked in the comment, here's the extract from the <code>Optgrp</code> entity class:</p>
  
  <pre><code>@Entity
  @NamedEntityGraph(name = "Optgrp.sysoptions", attributeNodes = @NamedAttributeNode("sysoptions"))
  public class Optgrp implements Serializable {
      [...]
      @OneToMany(mappedBy="optgrp", cascade = CascadeType.ALL, orphanRemoval=true)
      @OrderBy(clause = "ordnr ASC")
      private List&lt;Sysoption&gt; sysoptions = new ArrayList&lt;&gt;();
  }
  </code></pre>
  
  <p>And the <code>Sysoption</code> entity class as well:</p>
  
  <pre><code>@Entity
  public class Sysoption implements Serializable {
  [...]
      @ManyToOne
      @JoinColumn(name = "optgrp_id", insertable=false, updatable=false)
      private Optgrp optgrp;
  }
  </code></pre>