jakartaee/data

Apply EntityGraph Definition on Query Method

hantsy opened this issue · 4 comments

Specification Version

1.0.0-RC1

Bug report

If possible to apply the Entity Graph definitions on Entities to a specific query method in the Repositories? Spring Data JPA provides similar features for developers.

Additional information

For example,

@Entity
@NamedEntityGraph(name="with-comments")
class Post{
   @OneToMany
   Set<Comment> comments
}
interface PostRepository {

    @Find
    @EntityGraph(name="with-comments")
    Post findById(Long id);
}

This is not in the spec, since it would be a very Java Persistence-specific feature.

Also, the annotations for defining named entity graphs are super-ugly and I'm not a fan of them at all.

We do already have a very similar feature to this in Hibernate Data Repositories, but it uses Hibernate's named fetch profiles stuff, which have a much more elegant annotation-based definition.

(When we define integration with Jakarta Persistence, this is something we can look at.)

Yes, it should be part of the JPA integration, but it seems there is no a JPA extended spec jakarta-data-jpa under Jakarta Data.

Jakarta Data is only in its 1.0 version. It is not a bug that Jakarta Data does not offer the suggested function. This issue should be an enhancement request, not a bug.