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

MongoDocumentBacking fails when updating a backed attribute

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0 M4
    • Fix Version/s: Backlog
    • Component/s: Cross-store
    • Labels:
      None

      Description

      When updating an Mongo backed attribute

        @RelatedDocument
        @Transient
        private ProductAttributes attributes;
      
      @Document
      public class ProductAttributes
      {
        private Map<String, Object> values;
      ...
      }
      

      the updated values are not persisted in MongoDB in this unit test:

        @Test
        public void testAttributes()
        {
          final Product p = new Product();
          p.setAttribute(FIXED_FOCAL_LENGTH, Integer.valueOf(100));
          transactionalSave(p);
          final Product p2 = productRepository.findOne(p.getId());
          assertNotSame(p, p2);
          assertEquals(Integer.valueOf(100), p2.getAttributes().get(FIXED_FOCAL_LENGTH));
          p.setAttribute(FIXED_FOCAL_LENGTH, Integer.valueOf(50));
          transactionalSave(p);
          final Product p3 = productRepository.findOne(p.getId());
          assertNotSame(p2, p3);
          // fails: expected 50, was 100 
          assertEquals(Integer.valueOf(50), p3.getAttributes().get(FIXED_FOCAL_LENGTH));
          productRepository.delete(p);
        }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                thomas.risberg Thomas Risberg
                Reporter:
                reinhardmaier Reinhard Maier
                Last updater:
                Oliver Gierke
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: