I use Mongo in its simplest avatar (in combination with Spring Data).
I have two (first class) entities (@Documents) A and B, where A has a link (@DBRef) B inside it. Everything works fine when creating A and B. However, when reading object A (by identifier), reference B is always null .
I believe that DBRefs are loaded by default (see http://static.springsource.org/spring-data/data-document/docs/current/reference/html/#mapping-usage-references ), but the behavior is currently against it. Any ideas why?
Going to Spring Mongo M5 data compilation resolved this. So there must be a mistake so far.
You are right, any DBRefs look forward to, but they are not look forward to (AFAIK). If A has a reference to B, when saving A, Spring Data / MongoDB does not automatically save B, you should.
// Incorrect, upon retrieval a.getB() == null A a = new A(); a.setB(new B()); repositoryA.save(a); // Correct (to the best of my knowledge) B b = repositoryB.save(new B()); A a = new A(); a.setB(b); repositoryA.save(a);
Source: https://habr.com/ru/post/1380423/More articles:How can I evaluate the result of a logical expression in a string format at runtime in C #? - c #How can I reference two stylesheets using ASP.Net MVC 3? - cssReplication of cascading dropdowns when updating / reverse navigation with autocomplete - javascriptCan Scala apply multiple implicit conversions in a single expression? - scalaHow can I create my own form or page in an installer based on the Inno installation? - inno-setupPython removes JSON substring - jsonhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1380425/what-is-the-difference-between-making-calls-to-mvc-controller-methods-and-wcf-web-api-rest-service-calls&usg=ALkJrhgGYV143lm-gtGTY3x4GVw_EfNUoQHow to add bzr to Android manifest: versionName - androidWhy is my Applescript adding a background image to the .dmg folder, getting the size wrong? - applescripttry-except inside a loop - pythonAll Articles