blinkfox / fenix

This is an extension library to the Spring Data JPA complex or dynamic SQL query. 这是一个比 MyBatis 更加强大的 Spring Data JPA 扩展库,为解决复杂动态 JPQL (或 SQL) 而生。https://blinkfox.github.io/fenix
https://blinkfox.github.io/fenix
Apache License 2.0
345 stars 72 forks source link

No property *** found for type *** #40

Closed shuangyue521 closed 3 years ago

shuangyue521 commented 3 years ago

使用自定义扩展方法继承FenixSimpleJpaRepository,使用@QueryFenix 注解时报错

自定义扩展CommonRepositoryImpl: public class CommonRepositoryImpl<T,ID extends Serializable> extends FenixSimpleJpaRepository<T, ID> implements CommonRepository<T,ID> {

private final EntityManager entityManager;

private final JpaEntityInformation<T, ?> entityInformation;

public CommonRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityManager = entityManager;
    this.entityInformation = entityInformation;
}
public CommonRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
    //super(domainClass, entityManager);
    //this.entityManager = entityManager;
    this(JpaEntityInformationSupport.getEntityInformation(domainClass, entityManager), entityManager);
}

} 。。。。。。省略实现方法 启动类: @SpringBootApplication @EnableJpaRepositories(repositoryBaseClass = CommonRepositoryImpl.class) public class DispatchApplication {

public static void main(String[] args) {
    SpringApplication.run(DispatchApplication.class, args);
}

}

@QueryFenix 注解所在方法

public interface MyframeTaskInfoRepository extends CommonRepository<MyframeTaskInfo,String> {

@Query(value="select new Map(t.taskId as taskId,t.taskName as taskName)  from MyframeTaskInfo t where t.taskStatus = '1' and t.packageId =:packageId ")
List<Map<String, Object>> getTaskInfoByPackageId(@Param("packageId") String packageId);

@Query("select count(1) from MyframeTaskInfo t where t.relationTaskIds like :taskId")
List<Integer> findByRelationTaskIdsLike(@Param("taskId")String taskId);

@QueryFenix
List<TaskVo> getAllTaskDetailInfo();

}

启动报错: Caused by: org.springframework.data.mapping.PropertyReferenceException: No property getAllTaskDetailInfo found for type MyframeTaskInfo!

blinkfox commented 3 years ago

你代码不全,不一定看得出问题,你用 @EnableFenix试试,在这个注解中写 repositoryFactoryBeanClass=FenixJpaRepositoryFactoryBean.class, repositoryBaseClass=CommonRepositoryImpl.class。实在不行,可以跟一下我的源码,看看,是不是少些啥东西了

shuangyue521 commented 3 years ago

你代码不全,不一定看得出问题,你用 @EnableFenix试试,在这个注解中写 repositoryFactoryBeanClass=FenixJpaRepositoryFactoryBean.class, repositoryBaseClass=CommonRepositoryImpl.class。实在不行,可以跟一下我的源码,看看,是不是少些啥东西了

问题已解决,多谢