-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MongoTemplate doFind for ad-hoc query method visibility as protected. #4498
base: main
Are you sure you want to change the base?
Conversation
This is by design as we do not want to expose the method. It has a very large number of arguments and exposing it removes our desire to freely change the method. Let's take a step back: Can you elaborate on what you're trying to achieve? |
Sure! We had to do some work around add filters to the query due to our system being multitenant and we wanted to avoid to add We extended https://github.com/aleixmorgadas/spring-boot-data-mongo-multitenant You can see that we added the specific class into The library isn't the best but it works. |
@aleixmorgadas thanks for providing additional information - In the light of this PR I think it would make sense to revisit #2067 and maybe even spring-projects/spring-data-commons#766. |
I'm happy to help here. Right now, I took the approach of extending the behaviour via the I think it helps making the Repository more obvious by being: interface UserRepository extends MultiTenantCrudRepository<User, ObjectId> {
String tenantField() {
return "tenant";
}
} Instead of interface UserRepository extends CrudRepository<User, ObjectId> {
}
@MultiTenant
@Document
class User {
@Id
ObjectId id;
@MultiTenantField
String tenant;
} |
Hi there, All of these ultimately are blocked by this change. In light of that I would like to request that this be given a higher priority. |
There's some tension in exposing internal methods because we have over time a lot of changes to internals. If your application would rely on these methods, these would break quite often. Instead it would make rather sense to introduce query post-processing hooks with a well-defined API. |
Hi, thanks for the quick reply, I understand your position, my goal is to simply try and facilitate getting the ball moving on those tickets I listed, I am not partial to the way this ticket gets resolved. |
To add, it seems like there are no hard blocker to accomplishing any of the features on any of those tickets, and it seems like there is simply a lack of cross-communication between the projects, perhaps it would help to get all the respective folks involved in one conversation. |
Need:
The method that's being called when using method-like queries has default package visibility, compared to other methods with protected visibility.
In order to extend
MongoTemplate
without placing the new class in theorg.springframework.data.mongodb.core
package, I added theprotected
as method visibility.