Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow disambiguating annotation on resource accessor methods #474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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