question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Mongo queries inexplicably return zero results after upgrading to 3.0.8.RELEASE or later (spring-boot dep mgmt: 2.3.10.RELEASE or later)

See original GitHub issue

I’ve created a repo to demonstrate the issue, at https://github.com/oliverlockwood/mongodb-issue-demonstration, based on following the guidelines at https://spring.io/guides/gs/accessing-data-mongodb/.

That repo has a clear README but I’ll highlight the main points here as well.

  • In terms of environment, I have a local Docker container running MongoDB version 4.2.14, mapping ports 27017 and 28017.
  • The Customer model class contains a map field, like: public Map<String, DataValue> additionalData;
  • There are custom read/write converters configured; we persist the map as an array of (name, value) tuples, viz: Screenshot 2021-05-26 at 14 18 26
  • We have a custom repository implementation which allows dynamic queries to be specified (in our real use-case, via REST query payloads; in the example repo, via hard-coding in the run() method)
  • The custom Mongo query we generate in the application (regardless of spring-data-mongodb version) is logged out as: Query: { "$and" : [{ "additionalData.name" : "a"}, { "additionalData.value" : "b"}]}, Fields: {}, Sort: {}
  • With spring-boot version 2.3.9.RELEASE (therefore spring-data-mongodb version 3.0.7.RELEASE) an entry is found as expected by this query
  • With spring-boot version 2.3.10.RELEASE or higher (therefore spring-data-mongodb version 3.0.8.RELEASE or higher) no results are found
  • Directly querying Mongo via the console, i.e. db.getCollection('customer').find({ "$and" : [{ "additionalData.name" : "a"}, { "additionalData.value" : "b"}]}) finds an entry as expected

I therefore conclude this is a regression in spring-data-mongodb, but I can’t for the life of me figure out why it stops returning results.

I hope this in combination with the repo is enough context for you to investigate; please advise if you need me to provide any more information.

Many thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
christophstroblcommented, May 28, 2021

thanks for reporting and the sample - we’ll have a look.

0reactions
mp911decommented, Aug 23, 2021

You can fix the issue immediately within your code by aligning the data model to the actual representation in your MongoDB documents. Other than that, we need to revisit the entire map and array position translation that isn’t planned short term.

Read more comments on GitHub >

github_iconTop Results From Across the Web

自定义Mongo查询升级到3.0.8后莫名其妙地返回零结果。释放或更高 ...
Custom Mongo queries inexplicably return zero results after upgrading to 3.0.8.RELEASE or later (spring-boot dep mgmt: 2.3.10.RELEASE or later).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found