Skip to content

Commit 1e4203c

Browse files
schaudermp911de
authored andcommitted
Corrects the description of constructor detection.
Closes #2401 Original pull request: #2402.
1 parent 3c5cf34 commit 1e4203c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/asciidoc/object-mapping.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ This means we need two fundamental steps:
1717
Spring Data automatically tries to detect a persistent entity's constructor to be used to materialize objects of that type.
1818
The resolution algorithm works as follows:
1919

20-
1. If there's a no-argument constructor, it will be used.
20+
1. If there is a single constructor, it is used.
21+
2. If there are multiple constructors and exactly one is annotated with `@PersistenceConstructor`, it is used.
22+
3. If there's a no-argument constructor, it is used.
2123
Other constructors will be ignored.
22-
2. If there's a single constructor taking arguments, it will be used.
23-
3. If there are multiple constructors taking arguments, the one to be used by Spring Data will have to be annotated with `@PersistenceConstructor`.
2424

2525
The value resolution assumes constructor argument names to match the property names of the entity, i.e. the resolution will be performed as if the property was to be populated, including all customizations in mapping (different datastore column or field name etc.).
2626
This also requires either parameter names information available in the class file or an `@ConstructorProperties` annotation being present on the constructor.
@@ -35,7 +35,7 @@ Please consult the section on store specific mappings for further details.
3535
To avoid the overhead of reflection, Spring Data object creation uses a factory class generated at runtime by default, which will call the domain classes constructor directly.
3636
I.e. for this example type:
3737
38-
[source, java]
38+
[source,java]
3939
----
4040
class Person {
4141
Person(String firstname, String lastname) { … }

0 commit comments

Comments
 (0)