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

Specify collection name without using of @Document [DATAMONGO-2525]

Open
#3,380 0 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

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

Description

Vladislav Ogol opened DATAMONGO-2525 and commented

I as a developer want to have an ability to manage collection names without specifying
@Document annotations, so that it will let me persist objects which are out of my control or which should not be coupled with persistent layer implementation in a custom named collections.

I think that the easiest way to do that is to let me provide own implementation of the MongoCollectionUtils class (probably with some more suitable class name) with the static method getPreferredCollectionName replaced with something like this:

public Supplier<String> getPreferredCollectionName(Class<?> entityClass) {
	return () -> StringUtils.uncapitalize(entityClass.getSimpleName());
}

So that the Supplier can be cached in MongoPersistentEntity for future use


Affects: 2.2.6 (Moore SR6)

1 votes, 2 watchers

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.