Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SpEL expression resolution for @Document "collection" field #391

Closed
dsibilio opened this issue Jul 18, 2019 · 6 comments · Fixed by #390
Closed

Support SpEL expression resolution for @Document "collection" field #391

dsibilio opened this issue Jul 18, 2019 · 6 comments · Fixed by #390
Assignees
Labels

Comments

@dsibilio
Copy link
Contributor

dsibilio commented Jul 18, 2019

It would be nice to be able to dynamically load a collection name using SpEL expressions.

Examples:

  • from property source:
    e.g.
@Document(collection = "${dynamic.collection.name}")
public class MyCollection 

@Document(collection = "#{@environment.getProperty('dynamic.collection.name')}")
public class MyCollection 
  • from bean field/method invocation:
@Document(collection = "#{@someBean.getCollectionName()}")
public class MyCollection 

Pull Requests

#390

@Thommynator
Copy link

Thommynator commented Aug 31, 2019

Hi, this feature would be really helpful. 👍
Right now I'm looking for a way to make the collection name configurable by a property file like in the first option.

I noticed that the pull request has merge conflicts. Are there any plans to add this feature in the near future? :)

Can anyone tell me the best practice for making the collection name configurable without this change?

@dsibilio
Copy link
Contributor Author

I noticed that the pull request has merge conflicts.

Thanks for noticing, I pulled the changes and solved the conflicts. The Travis CI pipeline for integration tests seems to be broken though :(

Can anyone tell me the best practice for making the collection name configurable without this change?

Without this feature, I think you'd have to work with changing the collection name reflectively at runtime (e.g. https://www.baeldung.com/java-reflection-change-annotation-params)

@christopheranderson
Copy link

@kushagraThapar - can you take a look at this?

@kushagraThapar
Copy link
Collaborator

@dsibilio I have moved the travis CI to Azure DevOps CI, which supports running the CI on PRs from forked repository.
I have tried running that on your PR, but there are still some hiccups. I will fix that asap.

@dsibilio
Copy link
Contributor Author

@kushagraThapar Thank you, let me know if I can help you with anything.

@kushagraThapar
Copy link
Collaborator

@dsibilio CI is running successfully on external PRs now. I will take a look at the PR tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants