Spring Data Commons
  1. Spring Data Commons
  2. DATACMNS-159

Example 1.16. Custom repository factory bean is outdated

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial 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...

        Activity

        Hide
        Oliver Gierke added a comment -

        Here's how the docs and the code actually differ:

        Docs: JpaRepositoryFactoryBean.getRepositoryFactory():RepositoryFactorySupport
        Actual: JpaRepositoryFactoryBean.createRepositoryFactory():RepositoryFactorySupport

        Docs: JpaRepositoryFactory.getRepositoryClass()
        Actual: JpaRepositoryFactory.getRepositoryBaseClass(RepositoryMetadata)

        Show
        Oliver Gierke added a comment - Here's how the docs and the code actually differ: Docs: JpaRepositoryFactoryBean.getRepositoryFactory():RepositoryFactorySupport Actual: JpaRepositoryFactoryBean.createRepositoryFactory():RepositoryFactorySupport Docs: JpaRepositoryFactory.getRepositoryClass() Actual: JpaRepositoryFactory.getRepositoryBaseClass(RepositoryMetadata)
        Hide
        Karl Bennett added a comment -

        Have submitted a pull request that should hopefully resolve this.

        Show
        Karl Bennett added a comment - Have submitted a pull request that should hopefully resolve this.

          People

          • Assignee:
            Oliver Gierke
            Reporter:
            C. TRAN-XUAN
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: