From 4a033b65b884b56523bcd8aea97249703b497935 Mon Sep 17 00:00:00 2001 From: Chirag Tailor Date: Fri, 18 Mar 2022 11:45:32 -0500 Subject: [PATCH 1/2] fix-docs-on-lifecycle-events-callbacks - Prepare branch --- pom.xml | 2 +- spring-data-jdbc-distribution/pom.xml | 2 +- spring-data-jdbc/pom.xml | 4 ++-- spring-data-relational/pom.xml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 2c64717780..119b6fbdec 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-relational-parent - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT pom Spring Data Relational Parent diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml index 0646c2846d..d3b5a8c961 100644 --- a/spring-data-jdbc-distribution/pom.xml +++ b/spring-data-jdbc-distribution/pom.xml @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT ../pom.xml diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml index 11114a795e..9856f7cde1 100644 --- a/spring-data-jdbc/pom.xml +++ b/spring-data-jdbc/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-jdbc - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT Spring Data JDBC Spring Data module for JDBC repositories. @@ -15,7 +15,7 @@ org.springframework.data spring-data-relational-parent - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT diff --git a/spring-data-relational/pom.xml b/spring-data-relational/pom.xml index a6eb48c891..a90c0080e3 100644 --- a/spring-data-relational/pom.xml +++ b/spring-data-relational/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-relational - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT Spring Data Relational Spring Data Relational support @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 2.4.0-SNAPSHOT + 2.4.0-fix-docs-on-lifecycle-events-callbacks-SNAPSHOT From f2cd7e6837ccfa29fd6c1a1daf68de5a14d70ae9 Mon Sep 17 00:00:00 2001 From: Chirag Tailor Date: Fri, 18 Mar 2022 11:46:39 -0500 Subject: [PATCH 2/2] Update java and reference doc info on lifecycle events/callbacks. --- .../core/mapping/event/BeforeConvertCallback.java | 2 +- .../relational/core/mapping/event/BeforeSaveCallback.java | 5 +++-- src/main/asciidoc/jdbc.adoc | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertCallback.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertCallback.java index 8a8ed2bf51..21a7116bd3 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertCallback.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertCallback.java @@ -19,7 +19,7 @@ /** * An {@link EntityCallback} that gets invoked before the aggregate is converted into a database change. The decision if - * the change will be an insert or update is made before this callback gets called. + * the change will be an insert or update is made after this callback gets called. * * @author Jens Schauder * @author Mark Paluch diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeSaveCallback.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeSaveCallback.java index da025c7e20..1ef5e5bbdc 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeSaveCallback.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeSaveCallback.java @@ -32,8 +32,9 @@ public interface BeforeSaveCallback extends EntityCallback { /** * Entity callback method invoked before an aggregate root is saved. Can return either the same or a modified instance * of the aggregate and can modify {@link MutableAggregateChange} contents. This method is called after converting the - * {@code aggregate} to {@link MutableAggregateChange}. Changes to the aggregate are not taken into account for - * saving. Use the {@link BeforeConvertCallback} to change the persistent the entity before being converted. + * {@code aggregate} to {@link MutableAggregateChange}. Changes to the aggregate are not taken into account to decide + * whether the change will be an insert or update. Use the {@link BeforeConvertCallback} to change the persistent the + * entity before being converted. * * @param aggregate the aggregate. * @param aggregateChange the associated {@link MutableAggregateChange}. diff --git a/src/main/asciidoc/jdbc.adoc b/src/main/asciidoc/jdbc.adoc index f9993ccd69..74309287e0 100644 --- a/src/main/asciidoc/jdbc.adoc +++ b/src/main/asciidoc/jdbc.adoc @@ -422,7 +422,7 @@ When your data base has an auto-increment column for the ID column, the generate One important constraint is that, after saving an entity, the entity must not be new any more. Note that whether an entity is new is part of the entity's state. With auto-increment columns, this happens automatically, because the ID gets set by Spring Data with the value from the ID column. -If you are not using auto-increment columns, you can use a `BeforeSave` listener, which sets the ID of the entity (covered later in this document). +If you are not using auto-increment columns, you can use a `BeforeConvert` listener, which sets the ID of the entity (covered later in this document). [[jdbc.entity-persistence.optimistic-locking]] === Optimistic Locking @@ -865,7 +865,7 @@ The following table describes the available events: This is the correct event if you want to set an id programmatically. | {javadoc-base}/org/springframework/data/relational/core/mapping/event/BeforeSaveEvent.html[`BeforeSaveEvent`] -| Before an aggregate root gets saved (that is, inserted or updated but after the decision about whether if it gets updated or deleted was made). +| Before an aggregate root gets saved (that is, inserted or updated but after the decision about whether if it gets inserted or updated was made). | {javadoc-base}org/springframework/data/relational/core/mapping/event/AfterSaveEvent.html[`AfterSaveEvent`] | After an aggregate root gets saved (that is, inserted or updated). @@ -900,7 +900,7 @@ Spring Data JDBC uses the `EntityCallback` API for its auditing support and reac This is the correct callback if you want to set an id programmatically. | {javadoc-base}/org/springframework/data/relational/core/mapping/event/BeforeSaveCallback.html[`BeforeSaveCallback`] -| Before an aggregate root gets saved (that is, inserted or updated but after the decision about whether if it gets updated or deleted was made). +| Before an aggregate root gets saved (that is, inserted or updated but after the decision about whether if it gets inserted or updated was made). | {javadoc-base}org/springframework/data/relational/core/mapping/event/AfterSaveCallback.html[`AfterSaveCallback`] | After an aggregate root gets saved (that is, inserted or updated).