diff --git a/pom.xml b/pom.xml
index d55079dbe8..764e43dd59 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.dataspring-data-commons
- 3.4.0-SNAPSHOT
+ 3.4.0-ISSUE-1432-SNAPSHOTSpring Data CoreCore Spring concepts underpinning every Spring Data module.
diff --git a/src/main/antora/modules/ROOT/pages/object-mapping.adoc b/src/main/antora/modules/ROOT/pages/object-mapping.adoc
index 380966c536..f67921a872 100644
--- a/src/main/antora/modules/ROOT/pages/object-mapping.adoc
+++ b/src/main/antora/modules/ROOT/pages/object-mapping.adoc
@@ -154,7 +154,7 @@ By default, Spring Data attempts to use generated property accessors and falls b
Let's have a look at the following entity:
.A sample entity
-[source, java]
+[source,java]
----
class Person {
@@ -165,14 +165,15 @@ class Person {
private String comment; <4>
private @AccessType(Type.PROPERTY) String remarks; <5>
+ private @Transient String summary; <6>
- static Person of(String firstname, String lastname, LocalDate birthday) { <6>
+ static Person of(String firstname, String lastname, LocalDate birthday) { <7>
return new Person(null, firstname, lastname, birthday,
Period.between(birthday, LocalDate.now()).getYears());
}
- Person(Long id, String firstname, String lastname, LocalDate birthday, int age) { <6>
+ Person(Long id, String firstname, String lastname, LocalDate birthday, int age) { <7>
this.id = id;
this.firstname = firstname;
@@ -201,7 +202,10 @@ With the design shown, the database value will trump the defaulting as Spring Da
Even if the intent is that the calculation should be preferred, it's important that this constructor also takes `age` as parameter (to potentially ignore it) as otherwise the property population step will attempt to set the age field and fail due to it being immutable and no `with…` method being present.
<4> The `comment` property is mutable and is populated by setting its field directly.
<5> The `remarks` property is mutable and is populated by invoking the setter method.
-<6> The class exposes a factory method and a constructor for object creation.
+<6> The `summary` property transient and will not be persisted as it is annotated with `@Transient`.
+Spring Data doesn't use Java's `transient` keyword to exclude properties from being persisted as `transient` is part of the Java Serialization Framework.
+Note that this property can be used with a persistence constructor, but its value will default to `null` (or the respective primitive initial value if the property type was a primitive one).
+<7> The class exposes a factory method and a constructor for object creation.
The core idea here is to use factory methods instead of additional constructors to avoid the need for constructor disambiguation through `@PersistenceCreator`.
Instead, defaulting of properties is handled within the factory method.
If you want Spring Data to use the factory method for object instantiation, annotate it with `@PersistenceCreator`.
diff --git a/src/main/java/org/springframework/data/annotation/PersistenceCreator.java b/src/main/java/org/springframework/data/annotation/PersistenceCreator.java
index 53616aec42..b4d0ad8ef8 100644
--- a/src/main/java/org/springframework/data/annotation/PersistenceCreator.java
+++ b/src/main/java/org/springframework/data/annotation/PersistenceCreator.java
@@ -22,6 +22,8 @@
/**
* Marker annotation to declare a constructor or factory method annotation as factory/preferred constructor annotation.
+ * Properties used by the constructor (or factory method) must refer to persistent properties or be annotated with
+ * {@link org.springframework.beans.factory.annotation.Value @Value(…)} to obtain a value for object creation.
*
* @author Mark Paluch
* @author Oliver Drotbohm
@@ -29,4 +31,5 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
-public @interface PersistenceCreator {}
+public @interface PersistenceCreator {
+}
diff --git a/src/main/java/org/springframework/data/annotation/Transient.java b/src/main/java/org/springframework/data/annotation/Transient.java
index 90b2a398d5..f3591fa9cf 100644
--- a/src/main/java/org/springframework/data/annotation/Transient.java
+++ b/src/main/java/org/springframework/data/annotation/Transient.java
@@ -22,13 +22,20 @@
import java.lang.annotation.Target;
/**
- * Marks a field to be transient for the mapping framework. Thus the property will not be persisted and not further
- * inspected by the mapping framework.
+ * Marks a field to be transient for the mapping framework. Thus, the property will not be persisted.
+ *
+ * Excluding properties from the persistence mechanism is separate from Java's {@code transient} keyword that serves the
+ * purpose of excluding properties from being serialized through Java Serialization.
+ *
+ * Transient properties can be used in {@link PersistenceCreator constructor creation/factory methods}, however they
+ * will use Java default values. We highly recommend using {@link org.springframework.beans.factory.annotation.Value
+ * SpEL expressions through @Value(…)} to provide a meaningful value.
*
* @author Oliver Gierke
* @author Jon Brisbin
+ * @author Mark Paluch
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { FIELD, METHOD, ANNOTATION_TYPE })
+@Target(value = { FIELD, METHOD, ANNOTATION_TYPE, RECORD_COMPONENT })
public @interface Transient {
}
diff --git a/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java b/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java
index 489a2e6457..750f3e9b44 100644
--- a/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java
+++ b/src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java
@@ -61,7 +61,7 @@ public AuditingHandlerSupport(PersistentEntities entities) {
/**
* Setter do determine if {@link Auditable#setCreatedDate(TemporalAccessor)}} and
* {@link Auditable#setLastModifiedDate(TemporalAccessor)} shall be filled with the current Java time. Defaults to
- * {@code true}. One might set this to {@code false} to use database features to set entity time.
+ * {@literal true}. One might set this to {@literal false} to use database features to set entity time.
*
* @param dateTimeForNow the dateTimeForNow to set
*/
@@ -71,7 +71,7 @@ public void setDateTimeForNow(boolean dateTimeForNow) {
/**
* Set this to true if you want to treat entity creation as modification and thus setting the current date as
- * modification date during creation, too. Defaults to {@code true}.
+ * modification date during creation, too. Defaults to {@literal true}.
*
* @param modifyOnCreation if modification information shall be set on creation, too
*/
diff --git a/src/main/java/org/springframework/data/domain/Window.java b/src/main/java/org/springframework/data/domain/Window.java
index d5c220b27c..9303bed20a 100644
--- a/src/main/java/org/springframework/data/domain/Window.java
+++ b/src/main/java/org/springframework/data/domain/Window.java
@@ -68,9 +68,9 @@ static Window from(List items, IntFunction extends ScrollPosition> p
int size();
/**
- * Returns {@code true} if this window contains no elements.
+ * Returns {@literal true} if this window contains no elements.
*
- * @return {@code true} if this window contains no elements
+ * @return {@literal true} if this window contains no elements
*/
@Override
boolean isEmpty();
@@ -102,7 +102,7 @@ default boolean isLast() {
* Returns whether the underlying scroll mechanism can provide a {@link ScrollPosition} at {@code index}.
*
* @param index
- * @return {@code true} if a {@link ScrollPosition} can be created; {@code false} otherwise.
+ * @return {@literal true} if a {@link ScrollPosition} can be created; {@literal false} otherwise.
* @see #positionAt(int)
*/
default boolean hasPosition(int index) {
diff --git a/src/main/java/org/springframework/data/expression/ValueExpression.java b/src/main/java/org/springframework/data/expression/ValueExpression.java
index 7ad6ad4d26..b5e701d468 100644
--- a/src/main/java/org/springframework/data/expression/ValueExpression.java
+++ b/src/main/java/org/springframework/data/expression/ValueExpression.java
@@ -48,7 +48,7 @@ default ExpressionDependencies getExpressionDependencies() {
/**
* Returns whether the expression is a literal expression (that doesn't actually require evaluation).
*
- * @return {@code true} if the expression is a literal expression; {@code false} if the expression can yield a
+ * @return {@literal true} if the expression is a literal expression; {@literal false} if the expression can yield a
* different result upon {@link #evaluate(ValueEvaluationContext) evaluation}.
*/
boolean isLiteral();
diff --git a/src/main/java/org/springframework/data/mapping/Alias.java b/src/main/java/org/springframework/data/mapping/Alias.java
index 7d581285b6..fb488af038 100644
--- a/src/main/java/org/springframework/data/mapping/Alias.java
+++ b/src/main/java/org/springframework/data/mapping/Alias.java
@@ -22,7 +22,7 @@
/**
* A container object which may or may not contain a type alias value. If a value is present, {@code isPresent()} will
- * return {@code true} and {@link #getValue()} will return the value.
+ * return {@literal true} and {@link #getValue()} will return the value.
*
* Additional methods that depend on the presence or absence of a contained value are provided, such as
* {@link #hasValue(Object)} or {@link #isPresent()}
diff --git a/src/main/java/org/springframework/data/mapping/PersistentEntity.java b/src/main/java/org/springframework/data/mapping/PersistentEntity.java
index b460f72f99..a3536533d8 100644
--- a/src/main/java/org/springframework/data/mapping/PersistentEntity.java
+++ b/src/main/java/org/springframework/data/mapping/PersistentEntity.java
@@ -47,9 +47,9 @@ public interface PersistentEntity> extends It
* Returns the {@link PreferredConstructor} to be used to instantiate objects of this {@link PersistentEntity}.
*
* @return {@literal null} in case no suitable constructor for automatic construction can be found. This usually
- * indicates that the instantiation of the object of that persistent entity is done through either a
- * customer {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom
- * conversion mechanisms entirely.
+ * indicates that the instantiation of the object of that persistent entity is done through either a customer
+ * {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom conversion
+ * mechanisms entirely.
* @deprecated since 3.0, use {@link #getInstanceCreatorMetadata()}.
*/
@Nullable
@@ -61,8 +61,8 @@ public interface PersistentEntity> extends It
*
* @return {@literal null} in case no suitable creation mechanism for automatic construction can be found. This
* usually indicates that the instantiation of the object of that persistent entity is done through either a
- * customer {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom
- * conversion mechanisms entirely.
+ * customer {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom conversion
+ * mechanisms entirely.
* @since 3.0
*/
@Nullable
@@ -136,8 +136,8 @@ default P getRequiredIdProperty() {
}
/**
- * Returns the version property of the {@link PersistentEntity}. Can be {@literal null} in case no version property
- * is available on the entity.
+ * Returns the version property of the {@link PersistentEntity}. Can be {@literal null} in case no version property is
+ * available on the entity.
*
* @return the version property of the {@link PersistentEntity}.
*/
@@ -145,8 +145,8 @@ default P getRequiredIdProperty() {
P getVersionProperty();
/**
- * Returns the version property of the {@link PersistentEntity}. Can be {@literal null} in case no version property
- * is available on the entity.
+ * Returns the version property of the {@link PersistentEntity}. Can be {@literal null} in case no version property is
+ * available on the entity.
*
* @return the version property of the {@link PersistentEntity}.
* @throws IllegalStateException if {@link PersistentEntity} does not define a {@literal version} property.
@@ -166,7 +166,7 @@ default P getRequiredVersionProperty() {
/**
* Obtains a {@link PersistentProperty} instance by name.
*
- * @param name The name of the property. Can be {@literal null}.
+ * @param name the name of the property. Can be {@literal null}.
* @return the {@link PersistentProperty} or {@literal null} if it doesn't exist.
*/
@Nullable
@@ -213,6 +213,28 @@ default P getPersistentProperty(Class extends Annotation> annotationType) {
*/
Iterable