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
Copy file name to clipboardExpand all lines: src/main/asciidoc/object-mapping/sdc-object-mapping.adoc
+5-5
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ The resolution algorithm works as follows:
18
18
1. If there is a no-argument constructor, it will be used.
19
19
Other constructors will be ignored.
20
20
2. If there is a single constructor taking arguments, it will be used.
21
-
3. If there are multiple constructors taking arguments, the one to be used by Spring Data will have to be annotated with `@PersistenceConstructor`.
21
+
3. If there are multiple constructors taking arguments, the one to be used by Spring Data will have to be annotated with `@PersistenceCreator`.
22
22
23
23
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.).
24
24
This also requires either parameter names information available in the class file or an `@ConstructorProperties` annotation being present on the constructor.
@@ -201,7 +201,7 @@ Even if the intent is that the calculation should be preferred, it's important t
201
201
<.> The `comment` property is mutable is populated by setting its field directly.
202
202
<.> The `remarks` properties are mutable and populated by setting the `comment` field directly or by invoking the setter method for
203
203
<.> The class exposes a factory method and a constructor for object creation.
204
-
The core idea here is to use factory methods instead of additional constructors to avoid the need for constructor disambiguation through `@PersistenceConstructor`.
204
+
The core idea here is to use factory methods instead of additional constructors to avoid the need for constructor disambiguation through `@PersistenceCreator`.
205
205
Instead, defaulting of properties is handled within the factory method.
206
206
207
207
[[mapping.fundamentals.recommendations]]
@@ -214,7 +214,7 @@ If you need those, prefer to make them package protected so that they can only b
214
214
Constructor-only materialization is up to 30% faster than properties population.
215
215
* _Provide an all-args constructor_ --
216
216
Even if you cannot or don't want to model your entities as immutable values, there's still value in providing a constructor that takes all properties of the entity as arguments, including the mutable ones, as this allows the object mapping to skip the property population for optimal performance.
217
-
* _Use factory methods instead of overloaded constructors to avoid ``@PersistenceConstructor``_ --
217
+
* _Use factory methods instead of overloaded constructors to avoid ``@PersistenceCreator``_ --
218
218
With an all-argument constructor needed for optimal performance, we usually want to expose more application use case specific constructors that omit things like auto-generated identifiers etc.
219
219
It's an established pattern to rather use static factory methods to expose these variants of the all-args constructor.
220
220
* _Make sure you adhere to the constraints that allow the generated instantiator and property accessor classes to be used_
@@ -251,14 +251,14 @@ data class Person(val id: String, val name: String)
251
251
====
252
252
253
253
The class above compiles to a typical class with an explicit constructor.
254
-
We can customize this class by adding another constructor and annotate it with `@PersistenceConstructor` to indicate a constructor preference:
254
+
We can customize this class by adding another constructor and annotate it with `@PersistenceCreator` to indicate a constructor preference:
255
255
256
256
====
257
257
[source,java]
258
258
----
259
259
data class Person(var id: String, val name: String) {
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutableAuditableThingWithGeneratedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutablePersonWithExternallyGeneratedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutablePersonWithGeneratedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutableSecondPersonWithAssignedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutableSecondPersonWithExternallyGeneratedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/ImmutableSecondPersonWithGeneratedId.java
Copy file name to clipboardExpand all lines: src/test/java/org/springframework/data/neo4j/integration/shared/common/PersonWithRelationshipWithProperties.java
0 commit comments