Java 如何添加自定义方法所有服务spring数据

Java 如何添加自定义方法所有服务spring数据,java,spring,spring-data,Java,Spring,Spring Data,我为我的所有存储库自定义了一个存储库。我的子存储库具有相同的方法。代码在存储库实现下面 此界面: @NoRepositoryBean public interface BaseMyRepository<T, ID extends Serializable> extends JpaRepository<T, ID>{ List<T> findCustomNativeQuery(String sqlQuery); } @NoRepository

我为我的所有存储库自定义了一个存储库。我的子存储库具有相同的方法。代码在存储库实现下面

此界面:

 @NoRepositoryBean
 public interface BaseMyRepository<T, ID extends Serializable> extends JpaRepository<T, ID>{

     List<T> findCustomNativeQuery(String sqlQuery);
 }
@NoRepositoryBean
公共接口BaseMyRepository扩展了JpaRepository{
列出findCustomNativeQuery(字符串sqlQuery);
}
此实现类:

 public class BaseMyRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements BaseMyRepository<T, ID>{

     private final EntityManager entityManager;

     public BaseMyRepositoryImpl(JpaEntityInformation entityInformation, EntityManager entityManager){
         super(entityInformation, entityManager);
         this.entityManager = entityManager;
     }

     @Transactional
     @Override
     public List<T> findCustomNativeQuery(String sqlQuery) {
         List<T> lista = entityManager.createNativeQuery(sqlQuery, this.getDomainClass()).getResultList();

         return lista;
     }


 }
公共类BaseMyRepositoryImpl扩展了SimpleParepository实现BaseMyRepository{
私人最终实体管理人实体管理人;
公共基MyRepositoryImpl(JPAEEntityInformation entityInformation,EntityManager EntityManager){
超级(实体信息、实体管理器);
this.entityManager=entityManager;
}
@交易的
@凌驾
公共列表findCustomNativeQuery(字符串sqlQuery){
List lista=entityManager.createNativeQuery(sqlQuery,this.getDomainClass()).getResultList();
返回列表a;
}
}
这是我的存储库:

 public interface MyRepository extends BaseMyRepository<SmaempreEntity, Integer>{

 }
公共接口MyRepository扩展了BaseMyRepository{ } 现在我需要知道是否可能,请举例说明以下代码:

@服务
@交易的
公共类MyBaseService{
@自动连线
私人住宅;
公共列表findAll(){
返回R.findAll();
}
公共列表findCustomNativeQuery(字符串sqlQuery){
返回R.findCustomNativeQuery(sqlQuery);
}
}
公共类MyService扩展了MyBaseService{
}

您拥有所有代码,请尝试编译并运行它。还可以看到:我不知道如何运行
@Autowired
您拥有所有代码,请尝试编译并运行它。还可以看到:我不知道如何运行
@Autowired