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

Indexed affects not only root collection [DATAMONGO-1965]

Open
#2,836 8 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

  • #4600 by @rolag-it — closed without merging
for: team-attention type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Vadzim Parafianiuk opened DATAMONGO-1965 and commented

If I use @Indexed in one class, I want spring to create Index only in collection for this class, but it also creates index in another classes that use this @Indexed class as embedded field. As a result, if I use "unique = true" it also affects embedded fields in another classes. See my question on stackoverflow with more rich description and example.

 

I've found a solution: I create ApplicationListener, and after context loading I use MongoTemplate to create indexes manually. But it is not convenient


Reference URL: https://stackoverflow.com/questions/49930576/spring-data-mongodb-indexedunique-true-in-inner-field

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.