From aef37bd1296e5074cdc61621ee2be9e67eafddd0 Mon Sep 17 00:00:00 2001 From: Nathan Rauh Date: Thu, 12 Oct 2023 09:26:15 -0500 Subject: [PATCH] make built-in repositories use the lifecycle annotations Signed-off-by: Nathan Rauh --- .../main/java/jakarta/data/repository/BasicRepository.java | 6 ++++-- .../main/java/jakarta/data/repository/CrudRepository.java | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/jakarta/data/repository/BasicRepository.java b/api/src/main/java/jakarta/data/repository/BasicRepository.java index 035887a4c..3a29b710b 100644 --- a/api/src/main/java/jakarta/data/repository/BasicRepository.java +++ b/api/src/main/java/jakarta/data/repository/BasicRepository.java @@ -56,8 +56,7 @@ public interface BasicRepository extends DataRepository { * database differs from the version in the entity. * @throws NullPointerException If the provided entity is {@literal null}. */ - // TODO Jakarta Validation-related doc was found to be inconsistent with the Jakarta Validation spec - // so it is removed from the save methods for now. Pull #231 will be making corrections. + @Save S save(S entity); /** @@ -81,6 +80,7 @@ public interface BasicRepository extends DataRepository { * that differs from the version in the database. * @throws NullPointerException If either the iterable is null or any element is null. */ + @Save Iterable saveAll(Iterable entities); /** @@ -152,6 +152,7 @@ public interface BasicRepository extends DataRepository { * or has a version for optimistic locking that is inconsistent with the version in the database. * @throws NullPointerException when the entity is null */ + @Delete void delete(T entity); /** @@ -174,6 +175,7 @@ public interface BasicRepository extends DataRepository { * or has a version for optimistic locking that is inconsistent with the version in the database. * @throws NullPointerException If either the iterable is null or contains null elements. */ + @Delete void deleteAll(Iterable entities); /** diff --git a/api/src/main/java/jakarta/data/repository/CrudRepository.java b/api/src/main/java/jakarta/data/repository/CrudRepository.java index d98421bcc..234fa73bc 100644 --- a/api/src/main/java/jakarta/data/repository/CrudRepository.java +++ b/api/src/main/java/jakarta/data/repository/CrudRepository.java @@ -47,6 +47,7 @@ public interface CrudRepository extends BasicRepository { * @throws UnsupportedOperationException for Key-Value and Wide-Column databases * that use an append model to write data. */ + @Insert void insert(T entity); /** @@ -60,6 +61,7 @@ public interface CrudRepository extends BasicRepository { * @throws UnsupportedOperationException for Key-Value and Wide-Column databases * that use an append model to write data. */ + @Insert void insertAll(Iterable entities); /** @@ -79,6 +81,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. */ + @Update boolean update(T entity); /** @@ -98,5 +101,6 @@ 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. */ + @Update int updateAll(Iterable entities); }