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

Example 1.16. Custom repository factory bean is outdated

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3 RC2
    • Component/s: Documentation
    • Labels:
      None

      Description

      I think the Example 1.16 Custom repository factory bean is outdated: the method name declared in the sample code is not right and the extends pragma doesn't look correct (tested in code).

      Instead, in my code, I've got something like that:

      public class MyRepositoryFactoryBean<T extends JpaRepository<S, ID>, S, ID extends Serializable> extends
              JpaRepositoryFactoryBean<T, S, ID> {
      
          /*
           * (non-Javadoc)
           * 
           * @see
           * org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean
           * #createRepositoryFactory(javax.persistence.EntityManager)
           */
          @Override
          protected RepositoryFactorySupport createRepositoryFactory(final EntityManager aEntityManager) {
              return new MyRepositoryFactory(...);
          }
      
          private static class MyRepositoryFactory extends JpaRepositoryFactory{
      
           public MyRepositoryImpl getTargetRepository(...) {
             return new MyRepositoryImpl(...);
           }
      
           public Class<? extends RepositorySupport> getRepositoryClass() {
             return MyRepositoryImpl.class;
          }
        }
      }
      

      My 2 cents...

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Gierke
              Reporter:
              ctranxuan C. TRAN-XUAN
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: