Skip to content

Commit f527c8a

Browse files
committed
Polishing.
Tweak wording. Add Override annotations. See #3200 Original pull request: #3201
1 parent feab68f commit f527c8a

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Diff for: src/main/antora/modules/ROOT/pages/repositories/custom-implementations.adoc

+17-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface CustomizedUserRepository {
2323
----
2424
class CustomizedUserRepositoryImpl implements CustomizedUserRepository {
2525
26+
@Override
2627
public void someCustomMethod(User user) {
2728
// Your custom implementation
2829
}
@@ -32,15 +33,21 @@ class CustomizedUserRepositoryImpl implements CustomizedUserRepository {
3233
[NOTE]
3334
====
3435
The most important part of the class name that corresponds to the fragment interface is the `Impl` postfix.
35-
You can customize the store specific postfix by setting `@Enable<StoreModule>Repositories#repositoryImplementationPostfix`.
36+
You can customize the store-specific postfix by setting `@Enable<StoreModule>Repositories(repositoryImplementationPostfix = …)`.
3637
====
3738

3839
[WARNING]
3940
====
40-
Historically Spring Data custom repository behaviour followed a https://docs.spring.io/spring-data/commons/docs/1.9.0.RELEASE/reference/html/#repositories.single-repository-behaviour[different naming pattern] that is not recommended but still supported.
41-
A type located in the same package as the repository interface, matching _repository interface name_ + _implementation postfix_, is considered a custom implementation and will be treated as such.
42-
This can lead to unexpected failures. +
43-
Please consider the old extension strategy deprecated, with the intention of removal in the next major version.
41+
Historically, Spring Data custom repository implementation discovery followed a
42+
https://docs.spring.io/spring-data/commons/docs/1.9.0.RELEASE/reference/html/#repositories.single-repository-behaviour[naming pattern]
43+
that derived the custom implementation class name from the repository allowing effectively a single custom implementation.
44+
45+
A type located in the same package as the repository interface, matching _repository interface name_ followed by _implementation postfix_,
46+
is considered a custom implementation and will be treated as a custom implementation.
47+
A class following that name can lead to undesired behavior.
48+
49+
We consider the single-custom implementation naming deprecated and recommend not using this pattern.
50+
Instead, migrate to a fragment-based programming model.
4451
====
4552

4653
The implementation itself does not depend on Spring Data and can be a regular Spring bean.
@@ -75,6 +82,7 @@ interface HumanRepository {
7582
7683
class HumanRepositoryImpl implements HumanRepository {
7784
85+
@Override
7886
public void someHumanMethod(User user) {
7987
// Your custom implementation
8088
}
@@ -89,10 +97,12 @@ interface ContactRepository {
8997
9098
class ContactRepositoryImpl implements ContactRepository {
9199
100+
@Override
92101
public void someContactMethod(User user) {
93102
// Your custom implementation
94103
}
95104
105+
@Override
96106
public User anotherContactMethod(User user) {
97107
// Your custom implementation
98108
}
@@ -127,6 +137,7 @@ interface CustomizedSave<T> {
127137
128138
class CustomizedSaveImpl<T> implements CustomizedSave<T> {
129139
140+
@Override
130141
public <S extends T> S save(S entity) {
131142
// Your custom implementation
132143
}
@@ -273,6 +284,7 @@ class MyRepositoryImpl<T, ID>
273284
this.entityManager = entityManager;
274285
}
275286
287+
@Override
276288
@Transactional
277289
public <S extends T> S save(S entity) {
278290
// implementation goes here

0 commit comments

Comments
 (0)