Skip to content

Commit

Permalink
allow disambiguating annotation on resource accessor methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Feb 22, 2024
1 parent 879e8f7 commit 3436fdc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/src/main/asciidoc/repository.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,30 @@ default void cleanup() {

A repository may have at most one resource accessor method.

A resource accessor method may be annotated with:

- one or more CDI qualifier types,
- `jakarta.persistence.PersistenceContext` or `jakarta.persistence.PersistenceUnit`, or
- `jakarta.annotation.Resource`.

In this case, the repository implementation should use such annotations to disambiguate the resource it uses to access the data store, according to the usual rules defined by CDI, Jakarta EE, or Jakarta Persistence.

For example, `@Resource` might be used to disambiguate a `DataSource` used to obtain JDBC ``Connection``s:

[source,java]
----
@Resource(name="documentDatabase")
DataSource connection();
----

Similarly, `@PersistenceContext` might be used to disambiguate a Jakarta Persistence persistence unit:

[source,java]
----
@PersistenceContext(unitName="documents")
EntityManager entityManager();
----

=== Query by Method Name

The Query by method mechanism allows for creating query commands by naming convention.
Expand Down

0 comments on commit 3436fdc

Please sign in to comment.