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

Repositories does not expose registered repository for proxy type

    XMLWordPrintable

    Details

      Description

      Converting an entity to an ID using DomainClassConverter.ToIdConverter fails if the entity instance is actually a proxy. This is because DomainClassConverter.ToIdConverter.matches(…) only checks for a repository with the sourceType.getType(). In the case of a Hibernate proxy, this type is EntityClass_$$jvst###_## but the repository is registered with the key EntityClass.

      For my application, the inability to convert a proxy causes an exception in Thymeleaf template generation, which prevents the page from loading completely.

      It may not be possible to know when the persistence provider will return a proxy or a raw entity. For example, the JpaRepository.getOne(…) method may return a proxy or may cause subsequent queries to return proxies. It would be helpful if DomainClassConverter attempted at least one additional match by going one step up in the class hierarchy (sort of like GenericConversionService.Converters.find(…) does it) because the entity class is the superclass of the proxy and this would prevent the failure.

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            mikemuske Mike Muske
            Last updater:
            Mark Paluch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: