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

Repositories should return repository for entity's super-type if available

    XMLWordPrintable

    Details

    • Sprint:
      55 - Evans SR2

      Description

      Exception
      java.lang.IllegalArgumentException: Cannot create self link for class com.asseco.mdfextcr.portal.domain.PZPSchrankaPodani! No persistent entity found!
      	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:81) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:64) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:32) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      	at org.springframework.data.web.PagedResourcesAssembler.createResource(PagedResourcesAssembler.java:144) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
      	at org.springframework.data.web.PagedResourcesAssembler.toResource(PagedResourcesAssembler.java:96) ~[spring-data-commons-1.8.0.RELEASE.jar:na]
      	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:220) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.resultToResources(AbstractRepositoryRestController.java:207) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      	at org.springframework.data.rest.webmvc.RepositoryEntityController.getCollectionResource(RepositoryEntityController.java:135) ~[spring-data-rest-webmvc-2.1.0.RELEASE.jar:na]
      
      
      PZPSchrankaPodani.java
      @Entity
      @DiscriminatorValue("POD")
      public class PZPSchrankaPodani extends PZPSchranka {...}
      
      PZPSchranka.java
      @Entity
      @Table(name="PZP_T_SCHRANKA")
      @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
      @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType=DiscriminatorType.STRING, length=3)
      @DiscriminatorValue("###")
      @SequenceGenerator(name="PZP_T_SCHRANKA_GENERATOR", sequenceName="SEQ_PZP_T_SCHRANKA", allocationSize=1)
      public abstract class PZPSchranka extends HibernateCommonImpl {...}
      

      I think, that the cause is in

      org.springframework.data.repository.support.Repositories
      package org.springframework.data.repository.support;
      public class Repositories implements Iterable<Class<?>> {
      private RepositoryFactoryInformation<Object, Serializable> getRepositoryFactoryInfoFor(Class<?> domainClass) {
      
      		Assert.notNull(domainClass, "Domain class must not be null!");
      
      		RepositoryFactoryInformation<Object, Serializable> repositoryInfo = repositoryFactoryInfos.get(ClassUtils
      				.getUserClass(domainClass));
      		return repositoryInfo == null ? EMPTY_REPOSITORY_FACTORY_INFO : repositoryInfo;
      	}
      }
      

      Which return null for subclass PZPSchrankaPodani, but it should return repository for parent PZPSchranka

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            vkralik Vladimir Kralik
            Last updater:
            Oliver Drotbohm
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: