eclipse-ee4j / eclipse-ee4j/jersey

Declarative Linking: Support @InjectLinkNoFollow on class level

Open
#3,310 5 comments 0 reactions 0 assignees View on GitHub
Priority: Major Type: Improvement
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When an entity (lets call it parent) in my application links to a collection of entities associated with the parent entity, the declarative linking follows all fields of parent, to check those entities for other links (that's how I understand it).

This causes all lazy loaded collections to get loaded, even if they are not serialized into json format. So I end up with a huge amount of DB queries.
I could avoid this scenario by annotating every field of an entity with @InjectLinkNoFollow but this is impracticable. In fact, all fields of all my models would need to be annotated.

It should be possible, at least, to annotate a class with this annotation to avoid the traversal of associated entities. Or, the traversal of related entities is turned off by default.

A rudimentary fix would be this: [https://github.com/jersey/jersey/compare/master...weaselmetal:release-2.19](https://github.com/jersey/jersey/compare/master...weaselmetal:release-2.19)
#### Affected Versions
[2.19]

Contributor guide

Open the contributing guide

Research direction

Start by locating Jersey's declarative linking implementation and the handling of @InjectLinkNoFollow, then compare the behavior with the linked 2.19 branch diff. Determine how class-level annotation support should prevent traversal of associated entities, and verify that the affected lazy-loaded collections are no longer traversed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.