-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Repository lookups by DocumentReference returning empty results #4033
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
Comments
While we're looking at the issue, using the target object as the reference should work. In this case the given User is considered the source for the pointer referencing the target document. List<Product> findAllByOwner(User owner); |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Thanks, in my case though I want to avoid the unnecessary lookup for the whole object since I know the id of the reference object I am interested in. I see there is a draft to fix this issue, thanks for that, looking forward to the fix. |
Using
spring-boot-starter-data-mongodb:2.6.6
I have the following code below with 2 documents,
User
andProduct
.Product
has aDocumentReference
to aUser
object. Using a repository for each document, lookups by id of typeString
work as expected. But lookups forProduct
based on theUser
DocumentReference using an id of typeString
return 0 results. However if I do the same lookup using an id of typeObjectId
I get back the correct set of results.I also discovered if I use
@MongoId(FieldType.STRING)
for the id property, the lookups forProduct
based on theUser
DocumentReference using an id of type String returns the correct results, but now lookups for the Product or User using id of type String returns empty results. To get back the right set of results I have to lookup Product or User with an id of type ObjectId, essentially the reverse behaviour of the first observation.Is it supposed to behave like this? I would expect the same behaviour when looking up documents using an id of type
String
.The code:
The text was updated successfully, but these errors were encountered: