-
Couldn't load subscription status.
- Fork 1.5k
DATAJPA-466 - Add support for lazy loading configuration via JPA 2.1 fetch-/loadgraph. #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Since we use the JPA 2.0 API by default it is difficult to test support for JPA 2.1 features. I tested this with an external project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make those constants public to be able to use them in repository definitions.
|
As per our discussion this morning:
|
… configuration via JPA 2.1 fetch-groups. Prepare issue branch.
…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. Original pull request: #74. ```java @entity @QueryEntity @NamedEntityGraphs(@NamedEntityGraph(name = "GroupInfo.members", attributeNodes = @NamedAttributeNode("members"))) public class GroupInfo { ... @manytomany List<GroupMember> members = new ArrayList<GroupMember>(); //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<GroupInfo, String> { @QueryHints(@QueryHint(name = "javax.persistence.fetchgraph", value = "GroupInfo.members")) GroupInfo getByGroupName(String name); } ```
…fetch-/loadgraph. Applied suggestions from code review. The EntityGraph to use can now be configured on query method level via the new @entitygraph annotation. The new method JpaQueryMethod#getEntityGraph analyses an @entitygraph annotation and constructs a new JpaEntityGraph value object that contains the information form the annotation. The new method AbstractJpaQuery#applyEntityGraphConfiguration tries to apply the given EntityGraph configuration if the used JPA persistence provider supports the JPA 2.1 spec. Changed the class path order such that EclipseLink is now placed before the eclipse dependency. EclipseLink references the JPA 2.1 API and allows us to provide type-safe support for the new JPA 2.1 features.
…fetch-/loadgraph. Renamed FetchGraphType to EntityGraphType.
…fetch-/loadgraph. Added additional test cases.
…fetch-/loadgraph. We now support load-graph / fetch-graph QueryHints on repository query methods, which are applied when a JPA 2.1 capable JPA implementation is used. We explicitly reject the usage of those hints in case the user is running a JPA 2.0 provider. FetchGraphs / LoadGraphs can now be defined on the Entity via the @NamedEntityGraphs annotation. @entity @QueryEntity @NamedEntityGraphs(@NamedEntityGraph(name = "GroupInfo.members", attributeNodes = @NamedAttributeNode("members"))) public class GroupInfo { @manytomany List<GroupMember> members = new ArrayList<GroupMember>(); //default fetch mode is "lazy". } The entity graph "GroupInfo.members" overwrites the fetch-mode of the members collection to be "eager". The entity graph to be used can now configured on a repository query method. @repository public interface GroupRepository extends CrudRepository<GroupInfo, String> { @entitygraph("GroupInfo.members") GroupInfo getByGroupName(String name); } The new method JpaQueryMethod#getEntityGraph analyses an @entitygraph annotation and constructs a new JpaEntityGraph value object that contains the information form the annotation. The new method AbstractJpaQuery#applyEntityGraphConfiguration tries to apply the given EntityGraph configuration if the used JPA persistence provider supports the JPA 2.1 spec. Changed the class path order such that EclipseLink is now placed before the eclipse dependency. EclipseLink references the JPA 2.1 API and allows us to provide type-safe support for the new JPA 2.1 features. Original pull request: #74.
…fetch-/loadgraph. We now support load-graph / fetch-graph QueryHints on repository query methods, which are applied when a JPA 2.1 capable JPA implementation is used. We explicitly reject the usage of those hints in case the user is running a JPA 2.0 provider. FetchGraphs / LoadGraphs can now be defined on the Entity via the @NamedEntityGraphs annotation. @entity @QueryEntity @NamedEntityGraphs(@NamedEntityGraph(name = "GroupInfo.members", attributeNodes = @NamedAttributeNode("members"))) public class GroupInfo { @manytomany List<GroupMember> members = new ArrayList<GroupMember>(); //default fetch mode is "lazy". } The entity graph "GroupInfo.members" overwrites the fetch-mode of the members collection to be "eager". The entity graph to be used can now configured on a repository query method. @repository public interface GroupRepository extends CrudRepository<GroupInfo, String> { @entitygraph("GroupInfo.members") GroupInfo getByGroupName(String name); } The new method JpaQueryMethod#getEntityGraph analyses an @entitygraph annotation and constructs a new JpaEntityGraph value object that contains the information form the annotation. The new method AbstractJpaQuery#applyEntityGraphConfiguration tries to apply the given EntityGraph configuration if the used JPA persistence provider supports the JPA 2.1 spec. Changed the class path order such that EclipseLink is now placed before the eclipse dependency. EclipseLink references the JPA 2.1 API and allows us to provide type-safe support for the new JPA 2.1 features. Original pull request: #74.
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.
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.