micronaut-projects / micronaut-projects/micronaut-data

micronaut data mongo not updating/saving/listing nested collection

Open
#3,276 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: example attached type: bug
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

Expected Behavior

micronaut data mongo should save/update/listing nested collection.collections

Actual Behaviour

I have a movie and nested movies, I want to update the nested and list all movies with nested, for example.

I've tried the same thing with spring data mongo and worked

mapping spring

@Document
public record Movie(
        @Id
        ObjectId id,
        String title,
        @DBRef
        Set<Movie> next
)  {
}

mapping micronaut

@Serdeable
@MappedEntity(value = "movies")
public record Movie(
        @Id
        @GeneratedValue
        ObjectId id,
        @Nullable
        String title,
        @Nullable
        @Relation(value = Relation.Kind.ONE_TO_MANY) //tried with mappedBy = "movies"
        Set<Movie> next
) {

}

Steps To Reproduce

repo https://github.com/brucemelo/micronaut-mongo-issue

Environment Information

macos
java 21

Example Application

https://github.com/brucemelo/micronaut-mongo-issue

Version

micronautVersion=4.7.3

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

Start with the reproduction repository at https://github.com/brucemelo/micronaut-mongo-issue and compare its Movie mapping with the issue's Micronaut Data annotations. Run the reproduction against Micronaut 4.7.3 and MongoDB, focusing on nested collection save, update, and listing behavior. Done means nested Movie records support the expected operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.