spring-projects/spring-data-jpa — pull request #74 by thomasdarimont (2014-03-24 15:25:11+00:00)
Title: DATAJPA-466 - Add support for lazy loading configuration via JPA 2.1 fetch-/loadgraph.

We now support loadgraph / fetchgraph QueryHints on repository query methods, which are applied when a JPA 2.1 capable JPA implementation is used, otherwise they are ignored.

FetchGraphs / LoadGraphs can now be defined on the Entity via the @NamedEntityGraphs annotation.
```java
@Entity
@QueryEntity
@NamedEntityGraphs(@NamedEntityGraph(name = "GroupInfo.members", attributeNodes = @NamedAttributeNode("members")))
public class GroupInfo {
...
@ManyToMany List members = new ArrayList(); //default fetch mode is "lazy".
}
```

The entity graph "GroupInfo.members" overwrites the fetch-mode of the members collection to be "eager".

The fetch graph to be used can now configured on a repository query method.
```java
@Repository
public interface GroupRepository extends CrudRepository {

@QueryHints(@QueryHint(name = "javax.persistence.fetchgraph", value = "GroupInfo.members"))
GroupInfo getByGroupName(String name);
}
```