Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1058

Using @Field("foo") with @Dbref breaking behavior.

    XMLWordPrintable

    Details

      Description

      When transitioning from 1.4.3.RELEASE to 1.6.0.RELEASE, the model below no longer returns with map

      Model

      @Document(collection="model")
      class Model {
      	@Id
      	ObjectId id;
              
      /**
      * Currently only works without @Field annotation
      */
          @Field("foo")
      	@DBRef
      	Map<String, Foo> mapOfFoos ; //assume Foo is a class
      }
      

      Repo

      public interface ModelDao extends MongoRepository<Model, ObjectId> {
      }
      
      public interface FooDao extends MongoRepository<Foo, ObjectId> {
      }
      

      Snippet of a unit test

      ...
      Model model = new Model();
      Map<String, Foo> mapOfFoos = new HashMap<String, Foo>();
      Foo foo = new Foo()
      fooDao.save(foo)
      mapOfFoo("somestring", foo)
      model.setMapOfFoos(mapOfFoo)
      modelDao.save(model);
      Model  retreivedModel = modelDao.findOne(model.getId());
      //retreivedModel.getMapOfFoos() returns null
      //EXPECTED (and previous behavior) retreivedModel.getMapOfFoos() not null
      

        Attachments

          Activity

            People

            Assignee:
            thomasd Thomas Darimont
            Reporter:
            allan Allan Chiou
            Last updater:
            Spring Issues Spring Issues
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: