Skip to content

Commit

Permalink
Merge pull request #292 from njr-11/make-built-in-repositories-comply…
Browse files Browse the repository at this point in the history
…-with-spec-usage-of-lifecycle-annotations

make built-in repositories use the lifecycle annotations
  • Loading branch information
otaviojava authored Oct 16, 2023
2 parents ddecf94 + aef37bd commit 7f87416
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
* 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 extends T> S save(S entity);

/**
Expand All @@ -81,6 +80,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
* that differs from the version in the database.
* @throws NullPointerException If either the iterable is null or any element is null.
*/
@Save
<S extends T> Iterable<S> saveAll(Iterable<S> entities);

/**
Expand Down Expand Up @@ -152,6 +152,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
* 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);

/**
Expand All @@ -174,6 +175,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
* 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<? extends T> entities);

/**
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/jakarta/data/repository/CrudRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface CrudRepository<T, K> extends BasicRepository<T, K> {
* @throws UnsupportedOperationException for Key-Value and Wide-Column databases
* that use an append model to write data.
*/
@Insert
void insert(T entity);

/**
Expand All @@ -60,6 +61,7 @@ public interface CrudRepository<T, K> extends BasicRepository<T, K> {
* @throws UnsupportedOperationException for Key-Value and Wide-Column databases
* that use an append model to write data.
*/
@Insert
void insertAll(Iterable<T> entities);

/**
Expand All @@ -79,6 +81,7 @@ public interface CrudRepository<T, K> extends BasicRepository<T, K> {
* @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);

/**
Expand All @@ -98,5 +101,6 @@ public interface CrudRepository<T, K> extends BasicRepository<T, K> {
* @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<T> entities);
}

0 comments on commit 7f87416

Please sign in to comment.