我在我的项目中使用了一个扩展QueryDslJpaRepository的全局自定义存储库:
public class CustomPagingAndSortingRepositoryImpl<T, ID extends Serializable> extends QueryDslJpaRepository<T, ID>
implements CustomPagingAndSortingRepository<T, ID> {和接口:
public interface CustomPagingAndSortingRepository<T, ID extends Serializable>
extends JpaRepository<T, ID>, QueryDslPredicateExecutor<T> {然后在我的配置中,我用以下方式对其进行注释:
@EnableJpaRepositories(repositoryBaseClass = CustomPagingAndSortingRepositoryImpl.class)一切都很好,但现在我试图通过使用spring-data-envers为我的实体添加审计支持,根据文档,我应该使用特定的存储库工厂bean类:
@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class, repositoryBaseClass = CustomPagingAndSortingRepositoryImpl.class)很明显,如果我这样做了,事情就不会正常工作,因为我的存储库现在将通过EnversRevisionRepositoryFactoryBean类创建,并且不再是CustomPagingAndSortingRepositoryImpl类型。
我怎么能支持这样的东西呢?我看不出有什么办法,因为我的自定义存储库已经需要从QueryDslJpaRepository扩展。
发布于 2017-06-09 13:00:56
我认为对您来说相关的部分是EnversRevisionRepositoryFactoryBean的这种方法
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
return EnversRevisionRepositoryImpl.class;
}在这里,您非常希望返回您的CustomPagingAndSortingRepositoryImpl。因此,我将尝试以下操作:
https://stackoverflow.com/questions/44449448
复制相似问题