Description
Bartosz Kielczewski opened DATACMNS-1208 and commented
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)
Affects: 2.0.1 (Kay SR1)
Reference URL: https://pastebin.com/V0qZigKK
Issue Links:
- DATAMONGO-1819 Discovering the preferred constructor lead to InaccessibleObjectException with Java 9
Referenced from: pull request #258, and commits d8cea8b, 875cb11
Backported to: 2.0.2 (Kay SR2)