persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Consider allowing @NamedEntityGraph at the method level

Open gavinking opened this issue 6 months ago • 2 comments

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

@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

gavinking avatar Jul 03 '25 07:07 gavinking