Spring Data MongoDB
  1. Spring Data MongoDB
  2. DATAMONGO-392

Updating an object does not write type information for objects to be updated

    Details

    • Sprint:
      Babbage - RC1 - Stage One

      Description

      I'm using quite complex domain model, that consist of instantiable domain classes as well as of abstract ones. I used 1.0.0.M5 version, and the type information (under _class key) was stored with object when it was necessary to be able to read it from database later. That worked perfectly for me till my upgrade to 1.0.0.RELEASE version that broke my application as it saves the objects without type information and later it is impossible to read it back to java model.

      What I found is that MappingMongoConverter.writeInternal(...) method that in turn calls addCustomTypeIfNecessary(...) (line 330) which puts type information into DBObject. During execution of convertToMongoType(...) (at line 851) removeTypeInfoRecursively(...) is called which clears type data saved earlier under _class key. I had to comment out this call in order to

      The first point is that there is a contradiction: why to save type information to DBObject if it is later removed by other method? The second point is that there should be a way to persist the type information inferred from runtime along the persisted object and not just the class definition.

      1. AttributeDescriptor.java
        7 kB
        Peter Melnikov
      2. StringType.java
        1 kB
        Peter Melnikov
      3. Type.java
        3 kB
        Peter Melnikov

        Issue Links

          Activity

          Hide
          Derek Hulley added a comment -

          Issue present in 1.1.1.RELEASE.
          Nested custom types are persisted without _class and cannot be read in.

          Show
          Derek Hulley added a comment - Issue present in 1.1.1.RELEASE. Nested custom types are persisted without _class and cannot be read in.
          Hide
          Sid added a comment -

          Oliver, any chances of this getting fixed soon?

          Show
          Sid added a comment - Oliver, any chances of this getting fixed soon?
          Hide
          Thomas Darimont added a comment -

          Type information is now retained for updates.

          Should be fixed in the snapshots.
          Please give it a try

          Show
          Thomas Darimont added a comment - Type information is now retained for updates. Should be fixed in the snapshots. Please give it a try
          Hide
          Sid added a comment -

          That was quick Thomas. Is it possible for you to share the diff so that I patch my existing Springdata version? It will be risky for us to pull in 1.3 RC1 since we are almost code freeze for our release

          Show
          Sid added a comment - That was quick Thomas. Is it possible for you to share the diff so that I patch my existing Springdata version? It will be risky for us to pull in 1.3 RC1 since we are almost code freeze for our release
          Hide
          Thomas Darimont added a comment -
          Show
          Thomas Darimont added a comment - Hi Sid, sure, you can find it here: https://github.com/SpringSource/spring-data-mongodb/commit/b2fe54c0a17bad02e492dad99271d42ed74c337d Best regards, Thomas

            People

            • Assignee:
              Thomas Darimont
              Reporter:
              Peter Melnikov
            • Votes:
              9 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile