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

Strange generics behaviour for multiply nested generic types

    XMLWordPrintable

    Details

      Description

      This behaviour was incorrectly reported reopening DATACMNS-590 by me, sorry about that

      After the resolution of DATACMNS-590, we found another strange behaviour using Spring Data MongoDB, but only disabling the default type mapper resolution, which resolves the class type to map using an attribute. See github repo and run unit tests.

      I simplify a lot the domain model and use the generics in the minimal expression as possible to reproduce this, and I think now is much easier to understand.

      Take a close look at:

      • CustomerNonTypedRepositoryTest.testFindOne
      • CustomerNonTypedRepositoryTest.testFindOneItem

      Retrieving a Customer and navigate to ItemType will lead to a ClassCastException due the lost of generic type. But if we retrieve an Item and navigate to ItemType is ok.

      I know this is a corner case, and as said in DATACMNS-590 this will probably lead into a 'work-as-designed' resolution.

      We can't use the default type, because we are not using Spring to populate the database, but we think we can workaround this providing a custom type mapper.

      Thank you

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            padilo Pablo Díaz-López
            Last updater:
            Oliver Drotbohm
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: