spring-projects / spring-projects/spring-data-mongodb

Dedicated annotations to support Extended Reference Pattern

Open
#4,984 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

The Extended Reference data modeling pattern in MongoDB is one of the most popular and most powerful, but it's difficult to implement in Spring due to lack of support.

Im recommending creating two new annotations @ExtendedReference and @ExtendedAttribute to support this.

@ExtendedReference would be applied to a embedded object and used to identify that

  • The object needed to be persisted as an embedded document to the parent
  • The @Id or _id of the child object should always be included in the embedded fields
  • Only fields annotated with @ExtendedAttribute or with @Id or @MongoId should be persisted.

Fields with the @ExtendedReference annotation should never be retrieved via $lookup but if needed could be explicitly retrieved and set into the parent object.

This would allow users to take advantage of the extended reference pattern without

  • Creating new custom POJO's to represent the smaller version of the class
  • Having to do extensive custom serialization work
  • Impact any of the existing query operations in the spring-data library.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by mapping existing annotation and MongoDB persistence behavior, then clarify how embedded fields, identifiers, explicit retrieval, and query compatibility should be tested; done requires an agreed design and coverage for the proposed annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb, spring
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.