From 2537451ee3738fab14216e0e34920114ca786e1a Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 7 Oct 2023 05:49:46 +0100 Subject: [PATCH 01/21] docs: update changelog Signed-off-by: Otavio Santana --- CHANGELOG.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 73c2d4788..6ae3fc3b2 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -11,10 +11,13 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version === Added - Define Jakarta Data extensions +- Create BasicRepository +- Include insert and update methods in CrudRepository + === Changed -* Rename CrudRepository to BasicRepository +* Move the basic repository methods to the `BasicRepository` interface == [1.0.0-b3] - 2022-07-24 From d36f6f7a10c46e54742e7d21f1933480a1fef93d Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 7 Oct 2023 05:55:58 +0100 Subject: [PATCH 02/21] feat: update method to use S Signed-off-by: Otavio Santana --- .../main/java/jakarta/data/repository/CrudRepository.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index d98421bcc..c094ea3e6 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -47,7 +47,7 @@ public interface CrudRepository extends BasicRepository { * @throws UnsupportedOperationException for Key-Value and Wide-Column databases * that use an append model to write data. */ - void insert(T entity); + S insert(S entity); /** *

Inserts multiple entities into the database. If an entity of this type with the same @@ -60,7 +60,7 @@ public interface CrudRepository extends BasicRepository { * @throws UnsupportedOperationException for Key-Value and Wide-Column databases * that use an append model to write data. */ - void insertAll(Iterable entities); + Iterable insertAll(Iterable entities); /** *

Modifies an entity that already exists in the database.

@@ -79,7 +79,7 @@ public interface CrudRepository extends BasicRepository { * @return true if a matching entity was found in the database to update, otherwise false. * @throws NullPointerException if the entity is null. */ - boolean update(T entity); + S update(S entity); /** *

Modifies entities that already exists in the database.

@@ -98,5 +98,5 @@ public interface CrudRepository extends BasicRepository { * @return the number of matching entities that were found in the database to update. * @throws NullPointerException if either the iterable is null or any element is null. */ - int updateAll(Iterable entities); + Iterable updateAll(Iterable entities); } From 5a74901e2994795412e4f83d862df618effe1c35 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 7 Oct 2023 06:32:22 +0100 Subject: [PATCH 03/21] docs: enhance documentaiton at CrudRepository Signed-off-by: Otavio Santana --- .../data/repository/CrudRepository.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index c094ea3e6..d9b28ac04 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -38,27 +38,38 @@ public interface CrudRepository extends BasicRepository { /** *

Inserts an entity into the database. If an entity of this type with the same - * unique identifier already exists in the database, then this method raises - * {@link EntityExistsException}.

+ * unique identifier already exists in the database and the database supports ACID transactions, + * then this method raises {@link EntityExistsException}. In databases that follow the BASE model + * or use an append model to write data, this exception may not be thrown.

+ * + *

The entity instance returned as a result of this method may be the same instance as the one + * supplied as a parameter, especially in non-Java record classes. However, for Jakarta Data providers + * that support Java records, a different instance may be returned.

* * @param entity the entity to insert. Must not be {@code null}. - * @throws EntityExistsException if the entity is already present in the database. + * @param Type of the entity to insert. + * @return the inserted entity, which may or may not be a different instance depending on the Jakarta Data provider. + * @throws EntityExistsException if the entity is already present in the database (in ACID-supported databases). * @throws NullPointerException if the entity is null. - * @throws UnsupportedOperationException for Key-Value and Wide-Column databases - * that use an append model to write data. */ S insert(S entity); /** - *

Inserts multiple entities into the database. If an entity of this type with the same - * unique identifier as any of the given entities already exists in the database, - * then this method raises {@link EntityExistsException}.

+ *

Inserts multiple entities into the database. If any entity of this type with the same + * unique identifier as any of the given entities already exists in the database and the database + * supports ACID transactions, then this method raises {@link EntityExistsException}. + * In databases that follow the BASE model or use an append model to write data, this exception + * may not be thrown.

+ * + *

The entities within the returned iterable may be the same instances as those supplied + * as parameters, especially in non-Java record classes. However, for Jakarta Data providers + * that support Java records, different instances may be returned.

* * @param entities entities to insert. - * @throws EntityExistsException if any of the entities are already present in the database. - * @throws NullPointerException if either the iterable is null or any element is null. - * @throws UnsupportedOperationException for Key-Value and Wide-Column databases - * that use an append model to write data. + * @param Type of the entities to insert. + * @return an iterable containing the inserted entities, which may or may not be different instances depending on the Jakarta Data provider. + * @throws EntityExistsException if any of the entities are already present in the database (in ACID-supported databases). + * @throws NullPointerException if the iterable is null or any element is null. */ Iterable insertAll(Iterable entities); From 35b7a2c96fab3644320223dc19b1e326fa010e1d Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 7 Oct 2023 07:10:39 +0100 Subject: [PATCH 04/21] docs: update method documentation to the update method at CrudRepository Signed-off-by: Otavio Santana --- .../data/repository/CrudRepository.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index d9b28ac04..0c6f852c5 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -77,7 +77,9 @@ public interface CrudRepository extends BasicRepository { *

Modifies an entity that already exists in the database.

* *

For an update to be made, a matching entity with the same unique identifier - * must be present in the database.

+ * must be present in the database. In databases that use an append model to write data or + * follow the BASE model, this method will work similarly to the {@link #insert} method, + * especially if the database does not support ACID transactions.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by * another convention from the entity model such as having an attribute named {@code version}), @@ -87,16 +89,21 @@ public interface CrudRepository extends BasicRepository { *

Non-matching entities are ignored and do not cause an error to be raised.

* * @param entity the entity to update. - * @return true if a matching entity was found in the database to update, otherwise false. + * @param Type of the entity to update. + * @return the updated entity. The entity instance returned as a result of this method may be the same + * instance as the one supplied as a parameter, especially in non-Java record classes. However, + * for Jakarta Data providers that support Java records, a different instance may be returned. * @throws NullPointerException if the entity is null. */ S update(S entity); /** - *

Modifies entities that already exists in the database.

+ *

Modifies entities that already exist in the database.

* *

For an update to be made to an entity, a matching entity with the same unique identifier - * must be present in the database.

+ * must be present in the database. In databases that use an append model to write data or + * follow the BASE model, this method will work similarly to the {@link #insertAll} method, + * especially if the database does not support ACID transactions.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by * another convention from the entity model such as having an attribute named {@code version}), @@ -106,7 +113,10 @@ public interface CrudRepository extends BasicRepository { *

Non-matching entities are ignored and do not cause an error to be raised.

* * @param entities entities to update. - * @return the number of matching entities that were found in the database to update. + * @param Type of the entities to update. + * @return an iterable containing the updated entities. In the case of Jakarta Data providers + * that support Java records, this may return a different instance from the input, + * preserving immutability. * @throws NullPointerException if either the iterable is null or any element is null. */ Iterable updateAll(Iterable entities); From 18ade90cd16983ec70e0b7be92d21df3b34ae1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Sat, 7 Oct 2023 14:59:43 +0100 Subject: [PATCH 05/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 0c6f852c5..7209265d9 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -40,7 +40,7 @@ public interface CrudRepository extends BasicRepository { *

Inserts an entity into the database. If an entity of this type with the same * unique identifier already exists in the database and the database supports ACID transactions, * then this method raises {@link EntityExistsException}. In databases that follow the BASE model - * or use an append model to write data, this exception may not be thrown.

+ * or use an append model to write data, this exception is not thrown.

* *

The entity instance returned as a result of this method may be the same instance as the one * supplied as a parameter, especially in non-Java record classes. However, for Jakarta Data providers From d4088242757c619c54948417adc97c1b4ac4072d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Sat, 7 Oct 2023 15:00:17 +0100 Subject: [PATCH 06/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 7209265d9..cffdac42f 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -59,7 +59,7 @@ public interface CrudRepository extends BasicRepository { * unique identifier as any of the given entities already exists in the database and the database * supports ACID transactions, then this method raises {@link EntityExistsException}. * In databases that follow the BASE model or use an append model to write data, this exception - * may not be thrown.

+ * is not thrown.

* *

The entities within the returned iterable may be the same instances as those supplied * as parameters, especially in non-Java record classes. However, for Jakarta Data providers From 314e57b63a124bce34bd2c8241efaf10c096ad60 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 7 Oct 2023 15:52:12 +0100 Subject: [PATCH 07/21] docs: ehance the documentation at update method based on Nathan comments Signed-off-by: Otavio Santana --- .../main/java/jakarta/data/repository/CrudRepository.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index cffdac42f..514dd8909 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -78,8 +78,8 @@ public interface CrudRepository extends BasicRepository { * *

For an update to be made, a matching entity with the same unique identifier * must be present in the database. In databases that use an append model to write data or - * follow the BASE model, this method will work similarly to the {@link #insert} method, - * especially if the database does not support ACID transactions.

+ * follow the BASE model, this method behaves similarly to the {@link #insert} method, + * particularly in cases where the database does not support ACID transactions.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by * another convention from the entity model such as having an attribute named {@code version}), @@ -88,7 +88,7 @@ public interface CrudRepository extends BasicRepository { * *

Non-matching entities are ignored and do not cause an error to be raised.

* - * @param entity the entity to update. + * @param entity the entity to update. Must not be {@code null}. * @param Type of the entity to update. * @return the updated entity. The entity instance returned as a result of this method may be the same * instance as the one supplied as a parameter, especially in non-Java record classes. However, From 695266ff78fc66acbe7891b56c5e08bbcc7bc1f7 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Mon, 9 Oct 2023 12:18:14 +0100 Subject: [PATCH 08/21] docs: update documentation Signed-off-by: Otavio Santana --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 514dd8909..6c1075330 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -78,7 +78,7 @@ public interface CrudRepository extends BasicRepository { * *

For an update to be made, a matching entity with the same unique identifier * must be present in the database. In databases that use an append model to write data or - * follow the BASE model, this method behaves similarly to the {@link #insert} method, + * follow the BASE model, this method behaves as the {@link #insert} method, * particularly in cases where the database does not support ACID transactions.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by @@ -102,7 +102,7 @@ public interface CrudRepository extends BasicRepository { * *

For an update to be made to an entity, a matching entity with the same unique identifier * must be present in the database. In databases that use an append model to write data or - * follow the BASE model, this method will work similarly to the {@link #insertAll} method, + * follow the BASE model, this method behavior as the {@link #insertAll} method, * especially if the database does not support ACID transactions.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by From e38bf6b5e94d115609b6e5b20e24d579872cc4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 08:06:30 +0300 Subject: [PATCH 09/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 6c1075330..581f89a49 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -67,7 +67,7 @@ public interface CrudRepository extends BasicRepository { * * @param entities entities to insert. * @param Type of the entities to insert. - * @return an iterable containing the inserted entities, which may or may not be different instances depending on the Jakarta Data provider. + * @return an iterable containing the inserted entities, which may or may not be different instances depending on whether the insert caused values to be generated or automatically incremented. * @throws EntityExistsException if any of the entities are already present in the database (in ACID-supported databases). * @throws NullPointerException if the iterable is null or any element is null. */ From 9418d989b6052d94e665bbcb6253b45ac2bc216b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 08:06:48 +0300 Subject: [PATCH 10/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 581f89a49..9ab26ac7d 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -48,7 +48,7 @@ public interface CrudRepository extends BasicRepository { * * @param entity the entity to insert. Must not be {@code null}. * @param Type of the entity to insert. - * @return the inserted entity, which may or may not be a different instance depending on the Jakarta Data provider. + * @return the inserted entity, which may or may not be a different instance depending on whether the insert caused values to be generated or automatically incremented. * @throws EntityExistsException if the entity is already present in the database (in ACID-supported databases). * @throws NullPointerException if the entity is null. */ From 86558e183bc0e574d2d0b3d430e19546f7a0d714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 08:07:28 +0300 Subject: [PATCH 11/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- .../main/java/jakarta/data/repository/CrudRepository.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 9ab26ac7d..d2ebde427 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -42,9 +42,11 @@ public interface CrudRepository extends BasicRepository { * then this method raises {@link EntityExistsException}. In databases that follow the BASE model * or use an append model to write data, this exception is not thrown.

* - *

The entity instance returned as a result of this method may be the same instance as the one - * supplied as a parameter, especially in non-Java record classes. However, for Jakarta Data providers - * that support Java records, a different instance may be returned.

+ *

The entity instance returned as a result of this method must include all values that were + * written to the database, including all automatically generated values and incremented values + * that changed due to the insert. After invoking this method, do not continue to use the instance + * that is supplied as a parameter. This method makes no guarantees about the state of the + * instance that is supplied as a parameter.

* * @param entity the entity to insert. Must not be {@code null}. * @param Type of the entity to insert. From 5a9ffb01d546700d409d9c2a91dc3a98b20d12c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 22:03:22 +0300 Subject: [PATCH 12/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index d2ebde427..eca7a0b2a 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -104,8 +104,7 @@ public interface CrudRepository extends BasicRepository { * *

For an update to be made to an entity, a matching entity with the same unique identifier * must be present in the database. In databases that use an append model to write data or - * follow the BASE model, this method behavior as the {@link #insertAll} method, - * especially if the database does not support ACID transactions.

+ * follow the BASE model, this method behaves the same as the {@link #insertAll} method.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by * another convention from the entity model such as having an attribute named {@code version}), From b5fe8a0b6ac48a15634ba7cb6adc862fe7996637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 22:04:02 +0300 Subject: [PATCH 13/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index eca7a0b2a..88aa5fb38 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -80,8 +80,7 @@ public interface CrudRepository extends BasicRepository { * *

For an update to be made, a matching entity with the same unique identifier * must be present in the database. In databases that use an append model to write data or - * follow the BASE model, this method behaves as the {@link #insert} method, - * particularly in cases where the database does not support ACID transactions.

+ * follow the BASE model, this method behaves the same as the {@link #insert} method.

* *

If the entity is versioned (for example, with {@code jakarta.persistence.Version} or by * another convention from the entity model such as having an attribute named {@code version}), From a446e89970605ca59276585ab264a61b3dd84bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Wed, 11 Oct 2023 22:04:26 +0300 Subject: [PATCH 14/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- .../java/jakarta/data/repository/CrudRepository.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 88aa5fb38..184949bf9 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -63,9 +63,13 @@ public interface CrudRepository extends BasicRepository { * In databases that follow the BASE model or use an append model to write data, this exception * is not thrown.

* - *

The entities within the returned iterable may be the same instances as those supplied - * as parameters, especially in non-Java record classes. However, for Jakarta Data providers - * that support Java records, different instances may be returned.

+ *

The entities within the returned {@link Iterable} must include all values that were + * written to the database, including all automatically generated values and incremented values + * that changed due to the insert. After invoking this method, do not continue to use + * the entity instances that are supplied in the parameter. This method makes no guarantees + * about the state of the entity instances that are supplied in the parameter. + * The position of entities within the {@code Iterable} return value must correspond to the + * position of entities in the parameter based on the unique identifier of the entity.

* * @param entities entities to insert. * @param Type of the entities to insert. From 5059629707b686751e93d3437b7bef493d259904 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Wed, 11 Oct 2023 22:06:15 +0300 Subject: [PATCH 15/21] style: break the line at Crudrepository to avoid breaking the build Signed-off-by: Otavio Santana --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 184949bf9..7d1648552 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -73,7 +73,8 @@ public interface CrudRepository extends BasicRepository { * * @param entities entities to insert. * @param Type of the entities to insert. - * @return an iterable containing the inserted entities, which may or may not be different instances depending on whether the insert caused values to be generated or automatically incremented. + * @return an iterable containing the inserted entities, which may or may not be different instances depending + * on whether the insert caused values to be generated or automatically incremented. * @throws EntityExistsException if any of the entities are already present in the database (in ACID-supported databases). * @throws NullPointerException if the iterable is null or any element is null. */ From 73561621a238fbef9186b1c995ab7661510f4841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Mon, 16 Oct 2023 22:07:52 +0200 Subject: [PATCH 16/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- .../main/java/jakarta/data/repository/CrudRepository.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 93e746fa6..957938e2b 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -120,10 +120,7 @@ public interface CrudRepository extends BasicRepository { *

Non-matching entities are ignored and do not cause an error to be raised.

* * @param entities entities to update. - * @param Type of the entities to update. - * @return an iterable containing the updated entities. In the case of Jakarta Data providers - * that support Java records, this may return a different instance from the input, - * preserving immutability. + * @return the number of matching entities that were found in the database to update. * @throws NullPointerException if either the iterable is null or any element is null. */ @Update From c9ab742b6f74b5088c9e90216b12944796fa5da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Mon, 16 Oct 2023 22:08:00 +0200 Subject: [PATCH 17/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- .../main/java/jakarta/data/repository/CrudRepository.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 957938e2b..898fff03f 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -96,10 +96,7 @@ public interface CrudRepository extends BasicRepository { *

Non-matching entities are ignored and do not cause an error to be raised.

* * @param entity the entity to update. Must not be {@code null}. - * @param Type of the entity to update. - * @return the updated entity. The entity instance returned as a result of this method may be the same - * instance as the one supplied as a parameter, especially in non-Java record classes. However, - * for Jakarta Data providers that support Java records, a different instance may be returned. +@return true if a matching entity was found in the database to update, otherwise false. * @throws NullPointerException if the entity is null. */ @Update From 317eca8ff11ca2bbefa469df598a78e6b03b9a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Mon, 16 Oct 2023 22:08:10 +0200 Subject: [PATCH 18/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 898fff03f..641286027 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -100,7 +100,7 @@ public interface CrudRepository extends BasicRepository { * @throws NullPointerException if the entity is null. */ @Update - S update(S entity); + boolean update(T entity); /** *

Modifies entities that already exist in the database.

From 043ef874578f93cde399b79296ce0f25a843f4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Mon, 16 Oct 2023 22:08:18 +0200 Subject: [PATCH 19/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 641286027..748a16115 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -121,6 +121,6 @@ public interface CrudRepository extends BasicRepository { * @throws NullPointerException if either the iterable is null or any element is null. */ @Update - Iterable updateAll(Iterable entities); + int updateAll(Iterable entities); } From feee44b219656f909d35136d0c1cb316bd783c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Santana?= Date: Mon, 16 Oct 2023 22:30:04 +0200 Subject: [PATCH 20/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java Co-authored-by: Nathan Rauh --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 748a16115..451a5c02b 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -95,7 +95,7 @@ public interface CrudRepository extends BasicRepository { * *

Non-matching entities are ignored and do not cause an error to be raised.

* - * @param entity the entity to update. Must not be {@code null}. + * @return true if a matching entity was found in the database to update, otherwise false. @return true if a matching entity was found in the database to update, otherwise false. * @throws NullPointerException if the entity is null. */ From e3674173d19b2f1d9e4c428bb31276b7499ca1d8 Mon Sep 17 00:00:00 2001 From: Nathan Rauh Date: Mon, 16 Oct 2023 15:41:02 -0500 Subject: [PATCH 21/21] Update api/src/main/java/jakarta/data/repository/CrudRepository.java --- api/src/main/java/jakarta/data/repository/CrudRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index 451a5c02b..14e22e4c8 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -95,8 +95,8 @@ public interface CrudRepository extends BasicRepository { * *

Non-matching entities are ignored and do not cause an error to be raised.

* + * @param entity the entity to update. Must not be {@code null}. * @return true if a matching entity was found in the database to update, otherwise false. -@return true if a matching entity was found in the database to update, otherwise false. * @throws NullPointerException if the entity is null. */ @Update