Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
469 stars 52 forks source link

How to customize repository base class #11

Closed akkinoc closed 7 years ago

akkinoc commented 7 years ago

This library is what I was looking for. Thanks! However, I have a question.

How can I customize the repository base class? I want to use the function of Spring official document "Adding custom behavior to all repositories".

@NoRepositoryBean
public interface MyRepository<T, ID extends Serializable>
    extends EntityGraphJpaRepository<T, ID> {
    // ...
}
@Configuration
@EnableJpaRepositories(
    repositoryBaseClass = MyRepositoryImpl.class,  // <-- customized base class!
    repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class
)
public class DataRepositoryConfiguration {
    //...
}

So, I'm thinking to inherit EntityGraphSimpleJpaRepository as follows. But EntityGraphSimpleJpaRepository is not public...

public class MyRepositoryImpl<T, ID extends Serializable>
    extends EntityGraphSimpleJpaRepository<T, ID>
    implements MyRepository<T, ID> {
    // ...
}

Could you please support this?

Thanks.

reda-alaoui commented 7 years ago

Hello @akihyro , To allow customization, I turned the following classes into public classes:

Release 1.11.03 containing the fix has been performed. You will be able to use it in the next hour :)

akkinoc commented 7 years ago

Thanks for the quick fix! 👍