Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1208

AbstractMappingContext.hasPersistentEntity(…) does not consider cached abscence

    XMLWordPrintable

    Details

      Description

      For any simple type, i.e. Date:

      context.getPersistentEntity(Date::class.java) === null
      context.hasPersistentEntityFor(Date::class.java) == true

      Test case included.

      I think it's misleading and it has implications. For example in my use case it breaks repository sorting on any subsequent invocation with Spring Data Rest and Spring Data MongoDB. That's just for starters, for once a simple type 'leaks' there, it affects other operations.

      That's for PUT:

      Caused by: org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.String!
      at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:76)
      at org.springframework.data.mapping.context.PersistentEntities.lambda$getPersistentEntity$1(PersistentEntities.java:61)
      at java.util.Optional.map(Optional.java:215)
      at org.springframework.data.mapping.context.PersistentEntities.getPersistentEntity(PersistentEntities.java:61)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.mergeForPut(DomainObjectReader.java:141)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.lambda$mergeCollections$6(DomainObjectReader.java:460)
      at java.util.Optional.map(Optional.java:215)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.mergeCollections(DomainObjectReader.java:443)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.access$200(DomainObjectReader.java:68)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader$MergingPropertyHandler.doWithPersistentProperty(DomainObjectReader.java:646)
      at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:342)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.lambda$mergeForPut$0(DomainObjectReader.java:145)
      at java.util.Optional.map(Optional.java:215)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.mergeForPut(DomainObjectReader.java:141)
      at org.springframework.data.rest.webmvc.json.DomainObjectReader.readPut(DomainObjectReader.java:116)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              bkielczewski Bartosz Kielczewski
              Last updater:
              Mark Paluch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: