jakartaee / jakartaee/persistence

Consider allowing @NamedEntityGraph at the method level

Open
#735 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
268
Forks
78
Avg merge
1d 6h
Merged PRs (30d)
13

Description

I would love to be able to write a Jakarta Data repository method like this:

```java
@Find
@NamedEntityGraph(attributeNodes =
{@NamedAttributeNode(Author_.ADDRESS),
@NamedAttributeNode(Author_.BOOKS)})
Author author(String ssn);
```

But this doesn't work right now, because `NamedEntityGraph` is constrained to `@Target({TYPE})`.

I think we should consider relaxing that constraint to allow `@NamedEntityGraph` in other locations (e.g. package descriptors and methods).

An objection to this proposal could be that `NamedEntityGraph` is a bad name for this usage pattern, and that the annotation is generally quite verbose.

@njr-11

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the declaration and current uses of Jakarta Data's @NamedEntityGraph, especially its @Target({TYPE}) constraint and the repository method example. Determine whether method and package-descriptor placement should be supported, and document how the annotation name and verbosity affect the proposed API. Done means the scope and API direction are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.