You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section covers how to create instances and bean definitions for the defined repository interfaces.One way to do so is by using the Spring namespace that is shipped with each Spring Data module that supports the repository mechanism, although we generally recommend using Java configuration.
861
+
This section covers how to create instances and bean definitions for the defined repository interfaces.One way to do so is by using the Spring namespace that is shipped with each Spring Data module that supports the repository mechanism, although we generally recommend using Java configuration.
862
862
863
863
[[repositories.create-instances.spring]]
864
864
=== XML Configuration
@@ -916,7 +916,7 @@ The preceding example excludes all interfaces ending in `SomeRepository` from be
916
916
[[repositories.create-instances.java-config]]
917
917
=== Java Configuration
918
918
919
-
You can also trigger the repository infrastructure by using a store-specific `@Enable${store}Repositories` annotation on a Java configuration class.For an introduction to Java-based configuration of the Spring container, see {spring-framework-docs}/core.html#beans-java[JavaConfig in the Spring reference documentation].
919
+
You can also trigger the repository infrastructure by using a store-specific `@Enable${store}Repositories` annotation on a Java configuration class.For an introduction to Java-based configuration of the Spring container, see {spring-framework-docs}/core.html#beans-java[JavaConfig in the Spring reference documentation].
920
920
921
921
A sample configuration to enable Spring Data repositories resembles the following:
922
922
@@ -936,12 +936,12 @@ class ApplicationConfiguration {
936
936
----
937
937
====
938
938
939
-
NOTE: The preceding example uses the JPA-specific annotation, which you would change according to the store module you actually use.The same applies to the definition of the `EntityManagerFactory` bean.See the sections covering the store-specific configuration.
939
+
NOTE: The preceding example uses the JPA-specific annotation, which you would change according to the store module you actually use.The same applies to the definition of the `EntityManagerFactory` bean.See the sections covering the store-specific configuration.
940
940
941
941
[[repositories.create-instances.standalone]]
942
942
=== Standalone Usage
943
943
944
-
You can also use the repository infrastructure outside of a Spring container -- for example, in CDI environments.You still need some Spring libraries in your classpath, but, generally, you can set up repositories programmatically as well.The Spring Data modules that provide repository support ship with a persistence technology-specific `RepositoryFactory` that you can use, as follows:
944
+
You can also use the repository infrastructure outside of a Spring container -- for example, in CDI environments.You still need some Spring libraries in your classpath, but, generally, you can set up repositories programmatically as well.The Spring Data modules that provide repository support ship with a persistence technology-specific `RepositoryFactory` that you can use, as follows:
Extending the fragment interface with your repository interface combines the CRUD and custom functionality and makes it available to clients.
1008
1008
1009
-
Spring Data repositories are implemented by using fragments that form a repository composition.Fragments are the base repository, functional aspects (such as <<core.extensions.querydsl,QueryDsl>>), and custom interfaces along with their implementations.Each time you add an interface to your repository interface, you enhance the composition by adding a fragment.The base repository and repository aspect implementations are provided by each Spring Data module.
1009
+
Spring Data repositories are implemented by using fragments that form a repository composition.Fragments are the base repository, functional aspects (such as <<core.extensions.querydsl,QueryDsl>>), and custom interfaces along with their implementations.Each time you add an interface to your repository interface, you enhance the composition by adding a fragment.The base repository and repository aspect implementations are provided by each Spring Data module.
1010
1010
1011
1011
The following example shows custom interfaces and their implementations:
Repositories may be composed of multiple custom implementations that are imported in the order of their declaration.Custom implementations have a higher priority than the base implementation and repository aspects.This ordering lets you override base repository and aspect methods and resolves ambiguity if two fragments contribute the same method signature.Repository fragments are not limited to use in a single repository interface.Multiple repositories may use a fragment interface, letting you reuse customizations across different repositories.
1061
+
Repositories may be composed of multiple custom implementations that are imported in the order of their declaration.Custom implementations have a higher priority than the base implementation and repository aspects.This ordering lets you override base repository and aspect methods and resolves ambiguity if two fragments contribute the same method signature.Repository fragments are not limited to use in a single repository interface.Multiple repositories may use a fragment interface, letting you reuse customizations across different repositories.
1062
1062
1063
1063
The following example shows a repository fragment and its implementation:
0 commit comments