Skip to content

Commit 6b2b928

Browse files
authored
Merge pull request #562 from gavinking/two-changes
three minor changes
2 parents fcfa46e + 8269f3b commit 6b2b928

File tree

9 files changed

+16
-12
lines changed

9 files changed

+16
-12
lines changed

api/src/main/java/jakarta/data/repository/BasicRepository.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.util.Optional;
2626
import java.util.stream.Stream;
2727

28+
import static jakarta.data.repository.By.ID;
29+
2830
/**
2931
* <p>A built-in repository supertype for performing basic operations on entities.</p>
3032
*
@@ -141,7 +143,8 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
141143
* @return the entity with the given Id or {@link Optional#empty()} if none is found.
142144
* @throws NullPointerException when the Id is {@code null}.
143145
*/
144-
Optional<T> findById(K id);
146+
@Find
147+
Optional<T> findById(@By(ID) K id);
145148

146149
/**
147150
* Returns whether an entity with the given Id exists.
@@ -197,7 +200,8 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
197200
* @param id must not be {@code null}.
198201
* @throws NullPointerException when the Id is {@code null}.
199202
*/
200-
void deleteById(K id);
203+
@Delete
204+
void deleteById(@By(ID) K id);
201205

202206
/**
203207
* Deletes a given entity. Deletion is performed by matching the Id, and if the entity is

api/src/main/java/jakarta/data/repository/By.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* <p>The {@code By} annotation is unnecessary when the method parameter name
5959
* matches the entity attribute name and the application is compiled with the
6060
* {@code -parameters} compiler option that makes parameter names available
61-
* at run time.</p>
61+
* at runtime.</p>
6262
*
6363
* <p>Thus, when this compiler option is enabled, the previous example may be
6464
* written without the use of {@code By}:</p>

api/src/main/java/jakarta/data/repository/Param.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* <p>The {@code Param} annotation is unnecessary when the method parameter name
4444
* matches the query language named parameter name and the application is compiled with the
4545
* {@code -parameters} compiler option that makes parameter names available
46-
* at run time.</p>
46+
* at runtime.</p>
4747
*
4848
* @see Query
4949
*/

api/src/main/java/jakarta/data/repository/Query.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* The {@code Param} annotation is unnecessary for named parameters when the method parameter name
4343
* matches the query language named parameter name and the application is compiled with the
4444
* {@code -parameters} compiler option that makes parameter names available
45-
* at run time. When the {@code Param} annotation is not used, the Jakarta Data provider must
45+
* at runtime. When the {@code Param} annotation is not used, the Jakarta Data provider must
4646
* interpret the query by scanning for the delimiter that is used for positional parameters.
4747
* If the delimiter appears for another purpose in a query that requires named parameters,
4848
* it might be necessary for the application to explicitly define the {@code Param} in order to

api/src/main/java/jakarta/data/repository/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* and {@link jakarta.data.repository.CrudRepository#update(java.lang.Object)} operations.</li>
3131
* </ul>
3232
*
33-
* <p>Repository interfaces can also define their own life cycle methods using the
33+
* <p>Repository interfaces can also define their own lifecycle methods using the
3434
* {@link jakarta.data.repository.Insert}, {@link jakarta.data.repository.Update}, {@link jakarta.data.repository.Save}, and {@link jakarta.data.repository.Delete} annotations,
3535
* as well as a variety of other methods following the Query by Method Name pattern,
3636
* the Parameter-based Conditions pattern, and the {@link jakarta.data.repository.Query} annotation.</p>

api/src/main/java/module-info.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
* <p>Repository methods following the <b>Query by Method Name</b> pattern
237237
* must include the {@code By} keyword in the method name and must not include
238238
* the {@code @Find} annotation, {@code @Query} annotation, or
239-
* any life cycle annotations on the method or any data access related annotations
239+
* any lifecycle annotations on the method or any data access related annotations
240240
* on the method parameters. Query conditions
241241
* are determined by the portion of the method name following the {@code By} keyword.</p>
242242
*
@@ -572,7 +572,7 @@
572572
* If the {@link By} annotation is missing, the method parameter name must
573573
* match the name of an entity attribute and the repository must be compiled
574574
* with the {@code -parameters} compiler option so that parameter names are
575-
* available at run time. The {@code _} character may be used in a method
575+
* available at runtime. The {@code _} character may be used in a method
576576
* parameter name to reference embedded attributes. All conditions are
577577
* considered to be the equality condition. All conditions must match in
578578
* order to retrieve an entity.</p>

spec/src/main/asciidoc/repository.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ A _parameter-based automatic query method_ is an abstract method annotated with
826826

827827
Each automatic query method must be assigned an entity type. The rules for inferring the entity type depend on the semantics of the automatic query annotation. Typically:
828828

829-
- If the automatic query method returns an entity type, the method return type identifies the entity. For example, the return type might be `E`, `Optional<E>`, `Page<E>`, or `List<E>`, where `E` is an entity class. Then the automatic query method would be assigned the entity type `E`.
829+
- If the automatic query method returns an entity type, the method return type identifies the entity. For example, the return type might be `E`, `Optional<E>`, `E[]`, `Page<E>`, or `List<E>`, where `E` is an entity class. Then the automatic query method would be assigned the entity type `E`.
830830
- If the query does not return an entity type, the entity assigned to the automatic query method is the primary entity type of the repository.
831831

832832
Jakarta Data infers a query based on the parameters of the method. Each parameter must either:
@@ -1677,5 +1677,5 @@ The following order, with the lower number having higher precedence, is used whe
16771677
4. If the method is annotated with an <<Parameter-based automatic query methods,automatic query annotation>>, such as `@Find`, or with a <<Lifecycle methods,lifecycle annotation>> declaring the type of operation, for example, with `@Insert`, `@Update`, `@Save`, or `@Delete`, and the provider recognizes the annotation, then the annotation determines how the method is implemented, possibly with the help of other annotations present on the method parameters, for example, any `@By` annotations of the parameters.
16781678
5. If the method is named according to the conventions of _Query by Method Name_, then the implementation follows the <<Query by Method Name,_Query by Method Name_>> pattern.
16791679

1680-
A repository method that does not fit any of the above patterns and is not handled as a vendor-specific extension to the specification must either result in an error at build time or raise `UnsupportedOperationException` at run time.
1680+
A repository method that does not fit any of the above patterns and is not handled as a vendor-specific extension to the specification must either result in an error at build time or raise `UnsupportedOperationException` at runtime.
16811681

tck/src/main/java/ee/jakarta/tck/data/framework/read/only/CustomRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* Do not add methods or inheritance to this interface.
2727
* Its purpose is to test that without inheriting from a built-in repository,
28-
* the life cycle methods with the same entity class are what identifies the
28+
* the lifecycle methods with the same entity class are what identifies the
2929
* primary entity class to use for the count and exist methods.
3030
*/
3131
@Repository

tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ public void testPageOfNothing() {
13481348
assertEquals(0L, page.totalPages());
13491349
}
13501350

1351-
@Assertion(id = "133", strategy = "Use count and exists methods where the primary entity class is inferred from the life cycle methods.")
1351+
@Assertion(id = "133", strategy = "Use count and exists methods where the primary entity class is inferred from the lifecycle methods.")
13521352
public void testPrimaryEntityClassDeterminedByLifeCycleMethods() {
13531353
assertEquals(4, customRepo.countByIdIn(Set.of(2L, 15L, 37L, -5L, 60L)));
13541354

0 commit comments

Comments
 (0)