From b70209030b1b93c47786646d5da26173ffdb400e Mon Sep 17 00:00:00 2001
From: Otavio Santana The {@code Delete} annotation indicates to dynamic templates or repositories that the annotated method
+ * will perform a delete operation. This method should have a unique parameter whose type can be one of the following:
+ * The return type of the annotated method should be {@code void}, as the delete operation does not return a value.
+ * Deletion of a given entity is performed by matching the entity's Id. If the entity is versioned (e.g.,
+ * with {@code jakarta.persistence.Version}), the version is also checked for consistency during deletion.
+ * Properties other than the Id and version do not need to match for deletion.
+ * The {@code Insert} annotation indicates to dynamic templates or repositories that the annotated method
+ * will perform an insert operation. This method should have a unique parameter whose type can be one of the following:
+ * The return type of the annotated method should match the type of the parameter. For example, if the method is
+ * annotated with {@code @Insert} and takes a parameter of type {@code Car car}, the return type should be {@code Car}.
+ * Similarly, if the parameter is an {@code Iterable After invoking this method, it is recommended not to use the entity value supplied as a parameter, as this method
+ * makes no guarantees about the state of the entity value after insertion.
+ * If the entity uses optimistic locking, and the version differs from the version in the database, an
+ * {@link OptimisticLockingFailureException} may be thrown.
+ * For example, consider an interface representing a garage: The {@code @Insert} annotation can be used to indicate that the {@code parkCar} method is responsible for inserting
+ * a car entity into a database.
+ * The {@code Update} annotation indicates to dynamic templates or repositories that the annotated method
+ * will perform an update operation. This method should have a unique parameter whose type can be one of the following:
+ * The return type of the annotated method should be the same as the parameter type, ensuring consistency
+ * with the updated entity or entities.
+ * Updating an entity involves modifying its existing data in the database. The method will search for the entity
+ * in the database using its ID or key, and then update the corresponding record with the new data. After invoking
+ * this method, do not continue to use the entity value that is supplied as a parameter, as it may not accurately
+ * reflect the changes made during the update process.
+ * If the entity uses optimistic locking and its version differs from the version in the database,
+ * an {@link OptimisticLockingFailureException} will be thrown.
+ * For example, consider an interface representing a garage: The {@code Save} annotation indicates to dynamic templates or repositories that the annotated method
+ * will perform a save operation. This method should have a unique parameter whose type can be one of the following:
+ * The return type of the annotated method should be the same as the parameter type, ensuring consistency
+ * with the saved entity or entities.
+ * Saving an entity involves persisting it in the database. If the entity has an ID or key that already exists
+ * in the database, the method will update the existing record. If the entity does not exist in the database or has a
+ * null ID, this method will insert a new record. The entity instance returned by this method will be updated with
+ * any automatically generated or incremented values that changed due to the save operation.
+ * After invoking this method, avoid using the entity value that was supplied as a parameter, as it may not accurately
+ * reflect the changes made during the save process. If the entity uses optimistic locking and its version differs from
+ * the version in the database, an {@link OptimisticLockingFailureException} will be thrown.
+ * For example, consider an interface representing a garage: The {@code @Insert} annotation can be used to indicate that the {@code parkCar} method is responsible for inserting
+ * a car entity into a database.
+ *
+ *
+ *
+ *
+ *
+ * @Repository
+ * interface Garage {
+ * {@literal @}Insert
+ * Car parking(Car car);
+ * }
+ *
+ *
+ *
+ *
+ * * @Repository
+ * * interface Garage {
+ * * {@literal @}Update
+ * * Car update(Car car);
+ * * }
+ * *
+ * @return The updated entity; never {@literal null}.
+ * @throws OptimisticLockingFailureException If the entity uses optimistic locking and the version in the
+ * database differs from the version in the entity.
+ * @throws NullPointerException If the provided entity is {@literal null}.
+ *
+ * @see OptimisticLockingFailureException
+ */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java
index 549cbbe7e..4897daea1 100644
--- a/api/src/main/java/jakarta/data/repository/Save.java
+++ b/api/src/main/java/jakarta/data/repository/Save.java
@@ -24,6 +24,46 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ *
+ *
+ *
+ * @Repository
+ * interface Garage {
+ * {@literal @}Save
+ * Car parking(Car car);
+ * }
+ *
+ *
If the entity uses optimistic locking, and the version differs from the version in the database, an - * {@link OptimisticLockingFailureException} may be thrown. + * {@link jakarta.data.exceptions.OptimisticLockingFailureException} may be thrown. *
*For example, consider an interface representing a garage:
*@@ -56,7 +56,7 @@ * a car entity into a database. * * - * @see OptimisticLockingFailureException + * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index 9638b325f..e791ff3fa 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -43,7 +43,7 @@ * reflect the changes made during the update process. * ** @return The updated entity; never {@literal null}. - * @throws OptimisticLockingFailureException If the entity uses optimistic locking and the version in the + * @throws jakarta.data.exceptions.OptimisticLockingFailureException If the entity uses optimistic locking and the version in the * database differs from the version in the entity. * @throws NullPointerException If the provided entity is {@literal null}. * - * @see OptimisticLockingFailureException + * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index 4897daea1..e2ed2a6a7 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -43,7 +43,7 @@ * *If the entity uses optimistic locking and its version differs from the version in the database, - * an {@link OptimisticLockingFailureException} will be thrown. + * an {@link jakarta.data.exceptions.OptimisticLockingFailureException} will be thrown. *
* *For example, consider an interface representing a garage:
@@ -55,11 +55,11 @@ * * } * *
After invoking this method, avoid using the entity value that was supplied as a parameter, as it may not accurately * reflect the changes made during the save process. If the entity uses optimistic locking and its version differs from - * the version in the database, an {@link OptimisticLockingFailureException} will be thrown. + * the version in the database, an {@link jakarta.data.exceptions.OptimisticLockingFailureException} will be thrown. *
* *For example, consider an interface representing a garage:
@@ -58,11 +58,11 @@ * a car entity into a database. * * - * @throws OptimisticLockingFailureException If the entity uses optimistic locking and the version in the + * @throws jakarta.data.exceptions.OptimisticLockingFailureException If the entity uses optimistic locking and the version in the * database differs from the version in the entity. * @throws NullPointerException If the provided entity is {@literal null}. * - * @see OptimisticLockingFailureException + * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented @Retention(RetentionPolicy.RUNTIME) From 2ef630504054191e7a13d9274412da19be8154cf Mon Sep 17 00:00:00 2001 From: Otavio SantanaThe return type of the annotated method should be {@code void}, as the delete operation does not return a value. + *
The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). A boolean return type indicates whether or not an entity was deleted from the database. A numeric return type indicates how many entities were deleted from the database. *
*Deletion of a given entity is performed by matching the entity's Id. If the entity is versioned (e.g.,
* with {@code jakarta.persistence.Version}), the version is also checked for consistency during deletion.
From a21376f54e9fbd936170e931be1db5fc3825bae0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=
If the unique identifier of an entity is not found in the database or its version does not match, and the return type of the annotated method is {@code void} or {@code Void}, the method must raise {@link jakarta.data.exceptions.OptimisticLockingFailureException}.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
From d7482106a65de948f1626b7699ac7e86be9e69ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= The {@code Insert} annotation indicates to dynamic templates or repositories that the annotated method
- * will perform an insert operation. This method should have a unique parameter whose type can be one of the following:
+ * The {@code Insert} annotation indicates that the annotated repository method requests that one or more entities
+ * be inserted into the database. This method must have a single parameter whose type must be one of the following:
* The {@code Update} annotation indicates to dynamic templates or repositories that the annotated method
- * will perform an update operation. This method should have a unique parameter whose type can be one of the following:
+ * The {@code Update} annotation indicates that the annotated repository method requests that one or more entities
+ * be updated if found in the database. This method must have a single parameter whose type must be one of the following:
* The {@code Save} annotation indicates to dynamic templates or repositories that the annotated method
- * will perform a save operation. This method should have a unique parameter whose type can be one of the following:
+ * The {@code Save} annotation indicates that the annotated repository method
+ * updates one or more entities if found in the database
+ * and inserts entities into the database that are not found.
+ * This method must have a single parameter whose type must be one of the following:
* The return type of the annotated method should be the same as the parameter type, ensuring consistency
+ * The return type of the annotated method must be the same as the parameter type, ensuring consistency
* with the saved entity or entities.
* Saving an entity involves persisting it in the database. If the entity has an ID or key that already exists
From 0043b196e130b37c0fa12c73668f978f09de14ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= The {@code @Insert} annotation can be used to indicate that the {@code parkCar} method is responsible for inserting
+ * The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible for updating the entity in database if it already exists there and otherwise inserting
* a car entity into a database.
* If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Update},
+ * * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified. If the unique identifier of an entity is not found in the database or its version does not match, and the return type of the annotated method is {@code void} or {@code Void}, the method must raise {@link jakarta.data.exceptions.OptimisticLockingFailureException}.
*/
@Documented
diff --git a/api/src/main/java/jakarta/data/Insert.java b/api/src/main/java/jakarta/data/Insert.java
index a7b09559f..02e9b4bca 100644
--- a/api/src/main/java/jakarta/data/Insert.java
+++ b/api/src/main/java/jakarta/data/Insert.java
@@ -56,6 +56,9 @@
* a car entity into a database.
* If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete},
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified. If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete},
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
*
*
*
- *
The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). A boolean return type indicates whether or not an entity was deleted from the database. A numeric return type indicates how many entities were deleted from the database. + *
The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type + * (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). + * A boolean return type indicates whether or not an entity was deleted from the database. + * A numeric return type indicates how many entities were deleted from the database. *
*Deletion of a given entity is performed by matching the entity's Id. If the entity is versioned (e.g., * with {@code jakarta.persistence.Version}), the version is also checked for consistency during deletion. @@ -42,7 +45,9 @@ * * *
If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Update}, * * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
- *If the unique identifier of an entity is not found in the database or its version does not match, and the return type of the annotated method is {@code void} or {@code Void}, the method must raise {@link jakarta.data.exceptions.OptimisticLockingFailureException}. + *
If the unique identifier of an entity is not found in the database or its version does not match, and the return + * type of the annotated method is {@code void} or {@code Void}, the method must + * raise {@link jakarta.data.exceptions.OptimisticLockingFailureException}. */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index 24be022ff..1171ad863 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -56,7 +56,8 @@ * Car park(Car car); * } * - *
The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible for updating the entity in database if it already exists there and otherwise inserting + *
The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible + * for updating the entity in database if it already exists there and otherwise inserting * a car entity into a database. *
* From e33218dc45b314d13469a0977dd9b38af08113bc Mon Sep 17 00:00:00 2001 From: Otavio SantanaFor example, consider an interface representing a garage:
+ *+ * {@literal @}Repository + * interface Garage { + * {@literal @}Save + * Car unpark(Car car); + * } + ** *
If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Update}, * * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
*If the unique identifier of an entity is not found in the database or its version does not match, and the return diff --git a/api/src/main/java/jakarta/data/Insert.java b/api/src/main/java/jakarta/data/Insert.java index 02e9b4bca..4138b7c78 100644 --- a/api/src/main/java/jakarta/data/Insert.java +++ b/api/src/main/java/jakarta/data/Insert.java @@ -46,7 +46,7 @@ *
*For example, consider an interface representing a garage:
*- * @Repository + * {@literal @}Repository * interface Garage { * {@literal @}Insert * Car parking(Car car); diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index e96e7c17d..e2d20c1b6 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -47,13 +47,13 @@ * * ** *For example, consider an interface representing a garage:
- * *- * * @Repository - * * interface Garage { - * * {@literal @}Update - * * Car update(Car car); - * * } - * *+ *+ * @Repository + * interface Garage { + * {@literal @}Update + * Car update(Car car); + * } + **If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete}, * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
* @see jakarta.data.exceptions.OptimisticLockingFailureException diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index 1171ad863..c3f6b6f3b 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -50,7 +50,7 @@ * *For example, consider an interface representing a garage:
*- * @Repository + * {@literal @}Repository * interface Garage { * {@literal @}Save * Car park(Car car); From 94bc06da665d13610d755087ad6a0f6c3efdfc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=*Date: Thu, 5 Oct 2023 15:11:06 +0100 Subject: [PATCH 18/41] Update api/src/main/java/jakarta/data/Delete.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Delete.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/Delete.java b/api/src/main/java/jakarta/data/Delete.java index 3b1d04e87..7edf94db0 100644 --- a/api/src/main/java/jakarta/data/Delete.java +++ b/api/src/main/java/jakarta/data/Delete.java @@ -46,7 +46,7 @@ * * {@literal @}Repository * interface Garage { - * {@literal @}Save + * {@literal @}Delete * Car unpark(Car car); * } *From 7f99437f806ab2540351ba4c982116998e583ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=Date: Thu, 5 Oct 2023 15:11:19 +0100 Subject: [PATCH 19/41] Update api/src/main/java/jakarta/data/repository/Save.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/Save.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index c3f6b6f3b..c4fb2f233 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -57,7 +57,7 @@ * } * The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible - * for updating the entity in database if it already exists there and otherwise inserting + * for updating the entity in the database if it already exists there and otherwise inserting * a car entity into a database. *
* From 725f4ae64cad9a8f28a989ca4131e67d49dd6fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=Date: Thu, 5 Oct 2023 15:11:35 +0100 Subject: [PATCH 20/41] Update api/src/main/java/jakarta/data/Delete.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Delete.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/Delete.java b/api/src/main/java/jakarta/data/Delete.java index 7edf94db0..35178f979 100644 --- a/api/src/main/java/jakarta/data/Delete.java +++ b/api/src/main/java/jakarta/data/Delete.java @@ -25,8 +25,8 @@ import java.lang.annotation.Target; /** - * The {@code Delete} annotation indicates to dynamic templates or repositories that the annotated method - * will perform a delete operation. This method should have a unique parameter whose type can be one of the following: + *
The {@code Delete} annotation indicates that the annotated repository method requests one or more + * entities to be removed from the database. This method must have a single parameter whose type must be one of the following: *
**
- *- The entity to be deleted.
From dcd77f5d5ceee21f0ddcef378cf4568b3abd9de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=Date: Thu, 5 Oct 2023 15:18:06 +0100 Subject: [PATCH 21/41] Update api/src/main/java/jakarta/data/Insert.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Insert.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/Insert.java b/api/src/main/java/jakarta/data/Insert.java index 4138b7c78..f288c4d47 100644 --- a/api/src/main/java/jakarta/data/Insert.java +++ b/api/src/main/java/jakarta/data/Insert.java @@ -58,8 +58,6 @@ * * If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
- * - * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented @Retention(RetentionPolicy.RUNTIME) From b6f9bf2b1abe07e310b499abf8113dd870062b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=Date: Thu, 5 Oct 2023 15:18:31 +0100 Subject: [PATCH 22/41] Update api/src/main/java/jakarta/data/Update.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Update.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index e2d20c1b6..3c17ea94d 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -34,8 +34,7 @@ * - An {@code Iterable} of entities to be updated.
*- An array of entities to be updated.
*The return type of the annotated method should be the same as the parameter type, ensuring consistency - * with the updated entity or entities. + *
The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). A boolean return type indicates whether a matching entity was found in the database to update. A numeric return type indicates how many matching entities were found in the database to update. *
*Updating an entity involves modifying its existing data in the database. The method will search for the entity * in the database using its ID or key, and then update the corresponding record with the new data. After invoking From 51c266cb645a7e4e59f3dc1c06797df080da46ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=
Date: Thu, 5 Oct 2023 15:18:43 +0100 Subject: [PATCH 23/41] Update api/src/main/java/jakarta/data/Update.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Update.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index 3c17ea94d..16a06cd33 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -37,7 +37,7 @@ * The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). A boolean return type indicates whether a matching entity was found in the database to update. A numeric return type indicates how many matching entities were found in the database to update. *
*Updating an entity involves modifying its existing data in the database. The method will search for the entity - * in the database using its ID or key, and then update the corresponding record with the new data. After invoking + * in the database using its ID (and version, if versioned) and then update the corresponding record with the new data. After invoking * this method, do not continue to use the entity value that is supplied as a parameter, as it may not accurately * reflect the changes made during the update process. *
From 886fd529392ec99b9eeffa19c1225544a8d1ea40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=Date: Sat, 7 Oct 2023 05:30:39 +0100 Subject: [PATCH 24/41] Update api/src/main/java/jakarta/data/Delete.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/Delete.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/Delete.java b/api/src/main/java/jakarta/data/Delete.java index 35178f979..978cf57ef 100644 --- a/api/src/main/java/jakarta/data/Delete.java +++ b/api/src/main/java/jakarta/data/Delete.java @@ -51,7 +51,7 @@ * } *
If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Update}, - * * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * * {@code @Save}), it will throw an {@link UnsupportedOperationException} as only one operation type can be specified. *If the unique identifier of an entity is not found in the database or its version does not match, and the return
* type of the annotated method is {@code void} or {@code Void}, the method must
* raise {@link jakarta.data.exceptions.OptimisticLockingFailureException}.
From b7cf591372a1de66a312a7b896cdc1bfe2beba23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=
If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link UnsupportedOperationException} as only one operation type can be specified. */ @Documented @Retention(RetentionPolicy.RUNTIME) From e0807270fded00c59c3b0f3dcee87b095709f172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete}, - * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link UnsupportedOperationException} as only one operation type can be specified. * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented From ae297c7dd597ec42f431b81e1ae6cd0f45efa168 Mon Sep 17 00:00:00 2001 From: Otavio SantanaThe return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). A boolean return type indicates whether a matching entity was found in the database to update. A numeric return type indicates how many matching entities were found in the database to update. + *
The return type of the annotated method must be {@code void}, {@code boolean}, a numeric primitive type + * (such as {@code int}), or a corresponding primitive wrapper type (such as {@link Integer}). + * A boolean return type indicates whether a matching entity was found in the database to update. + * A numeric return type indicates how many matching entities were found in the database to update. *
*Updating an entity involves modifying its existing data in the database. The method will search for the entity
* in the database using its ID (and version, if versioned) and then update the corresponding record with the new data. After invoking
From cf60d689ad68e150b7584dff6d244b39d1bc6795 Mon Sep 17 00:00:00 2001
From: Otavio Santana
If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Save}), it will throw an {@link UnsupportedOperationException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified. */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index 84153e436..918cda162 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -57,7 +57,7 @@ * } * *If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete}, - * {@code @Save}), it will throw an {@link UnsupportedOperationException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified. * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index c4fb2f233..18ed3a4f8 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -56,12 +56,13 @@ * Car park(Car car); * } * - *The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible + *
The {@code @Update} annotation can be used to indicate that the {@code park(Car)} method is responsible * for updating the entity in the database if it already exists there and otherwise inserting * a car entity into a database. *
* - * + *If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, + * {@code @Insert}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
* @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented From 24774b852ea94ff086530b146d7bbfc79e2c1c6f Mon Sep 17 00:00:00 2001 From: Otavio SantanaIf this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where + * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime.. */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/api/src/main/java/jakarta/data/Update.java b/api/src/main/java/jakarta/data/Update.java index 918cda162..01a2ecd10 100644 --- a/api/src/main/java/jakarta/data/Update.java +++ b/api/src/main/java/jakarta/data/Update.java @@ -57,7 +57,8 @@ * } * *If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete}, - * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where + * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime. * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented diff --git a/api/src/main/java/jakarta/data/repository/Save.java b/api/src/main/java/jakarta/data/repository/Save.java index 18ed3a4f8..d317293f4 100644 --- a/api/src/main/java/jakarta/data/repository/Save.java +++ b/api/src/main/java/jakarta/data/repository/Save.java @@ -62,7 +62,8 @@ * * *If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Insert}), it will throw an {@link IllegalStateException} as only one operation type can be specified.
+ * {@code @Insert}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where + * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime. * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented From f83f081445dd6c4d27ab93ec269faa50c869855f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=The return type of the annotated method must be the same as the parameter type, ensuring consistency - * with the saved entity or entities. + *
The return type of an annotated method that requires a single entity as the parameter + * must have a return type that is {@code void}, {@code Void}, or the same type as the parameter. + * The return type of an annotated method that accepts an {@code Iterable} or array of entities + * as the parameter must have a return type that is {@code void}, {@code Void}, + * or an {@code Iterable} or array of the entity. *
*Saving an entity involves persisting it in the database. If the entity has an ID or key that already exists
* in the database, the method will update the existing record. If the entity does not exist in the database or has a
From 39d0497d4613ce2b47ecceb23f094f7d7a066e2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= The return type of the annotated method should match the type of the parameter. For example, if the method is
- * annotated with {@code @Insert} and takes a parameter of type {@code Car car}, the return type should be {@code Car}.
- * Similarly, if the parameter is an {@code Iterable The return type of an annotated method that requires a single entity as the parameter must have a return type that is {@code void}, {@code Void}, or the same type as the parameter.
+ * The return type of an annotated method that accepts an {@code Iterable} or array of entities as the parameter must have a return type that is {@code void}, {@code Void}, or an {@code Iterable} or array of the entity.
+ * For example, if the method is
+ * annotated with {@code @Insert} and takes a parameter of type {@code Car car}, the return type can be {@code Car}.
+ * Similarly, if the parameter is an {@code Iterable After invoking this method, it is recommended not to use the entity value supplied as a parameter, as this method
* makes no guarantees about the state of the entity value after insertion.
From 7c50b27a7a7ca12725ccf97bc7875ca96126df03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= The {@code @Update} annotation can be used to indicate that the {@code park(Car)} method is responsible
+ * The {@code @Save} annotation can be used to indicate that the {@code park(Car)} method is responsible
* for updating the entity in the database if it already exists there and otherwise inserting
* a car entity into a database.
* After invoking this method, avoid using the entity value that was supplied as a parameter, as it may not accurately
+ * Entities that are returned by the annotated method must include all values that were
+ * written to the database, including all automatically generated values and incremented values
+ * that changed due to the save. The position of entities within an {@code Iterable} or array return value
+ * must correspond to the position of entities in the parameter based on the unique identifier of the entity. After invoking this method, avoid using the entity value that was supplied as a parameter, because it might not accurately
* reflect the changes made during the save process. If the entity uses optimistic locking and its version differs from
* the version in the database, an {@link jakarta.data.exceptions.OptimisticLockingFailureException} will be thrown.
* If this annotation is combined with other operation annotations (e.g., {@code @Insert}, {@code @Delete},
- * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where
- * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime.
If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Save}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where - * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime..
+ * {@code @Save}), it will throw an {@link UnsupportedOperationException} because only one operation type can be specified. + * A Jakarta Data provider implementation must detect (and report) this error at compile time or at runtime. */ @Documented @Retention(RetentionPolicy.RUNTIME) From 772d83eca7846b6cb4dfab74b0194a14109d7452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete}, - * {@code @Insert}), it will throw an {@link IllegalStateException} as only one operation type can be specified, where - * a Jakarta Data provider implementation choose to detect (and report) this error at compile time or at runtime.
+ * {@code @Insert}), it will throw an {@link UnsupportedOperationException} because only one operation type can be specified. + * A Jakarta Data provider implementation must detect (and report) this error at compile time or at runtime. * @see jakarta.data.exceptions.OptimisticLockingFailureException */ @Documented From cb01577c762ed854c75e6500cc8f215d8c177bb3 Mon Sep 17 00:00:00 2001 From: Otavio SantanaThe return type of an annotated method that requires a single entity as the parameter must have a return type that is {@code void}, {@code Void}, or the same type as the parameter. - * The return type of an annotated method that accepts an {@code Iterable} or array of entities as the parameter must have a return type that is {@code void}, {@code Void}, or an {@code Iterable} or array of the entity. - * For example, if the method is - * annotated with {@code @Insert} and takes a parameter of type {@code Car car}, the return type can be {@code Car}. + *
The return type of an annotated method that requires a single entity as the parameter must have a return type
+ * that is {@code void}, {@code Void}, or the same type as the parameter.
+ * The return type of an annotated method that accepts an {@code Iterable} or array of entities as the parameter must
+ * have a return type that is {@code void}, {@code Void}, or an {@code Iterable} or array of the entity.
+ * For example, if the method is annotated with {@code @Insert} and takes a parameter of type {@code Car car},
+ * the return type can be {@code Car}.
* Similarly, if the parameter is an {@code Iterable After invoking this method, it is recommended not to use the entity value supplied as a parameter, as this method
* makes no guarantees about the state of the entity value after insertion.
* If the entity uses optimistic locking, and the version differs from the version in the database, an
- * {@link jakarta.data.exceptions.OptimisticLockingFailureException} may be thrown.
+ * If an entity of this type with the same unique identifier already exists in the database
+ * and the databases performs ACID (atomic, consistent, isolated, durable) transactions,
+ * then annotated method raises {@link jakarta.data.exceptions.EntityExistsException}.
+ * In databases that follow the BASE model or use an append model to write data,
+ * this exception is not thrown.
* For example, consider an interface representing a garage: The {@code @Insert} annotation can be used to indicate that the {@code parkCar} method is responsible for inserting
- * a car entity into a database.
+ * The {@code @Insert} annotation can be used to indicate that the {@code park(Car)} method is responsible for inserting
+ * a {@code Car} entity into a database.
* If this annotation is combined with other operation annotations (e.g., {@code @Update}, {@code @Delete},
From 3ef795cbf77ffdce5dd4c4d88a245fc05871c619 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= If the entity uses optimistic locking and its version differs from the version in the database,
- * an {@link jakarta.data.exceptions.OptimisticLockingFailureException} will be thrown.
+ * If the entity does not exist in the database or it is versioned and its version differs from the version in the database,
+ * no update is made and no error is raised.
* For example, consider an interface representing a garage:
From 050096e3c9f5eeb32bc4a96d149c28f4a8cd73e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ot=C3=A1vio=20Santana?=
- *