Spring QueryDslPredicateExecutor 的数据没有 属性 findAll 发现类型错误
Spring Data with QueryDslPredicateExecutor no property findAll found for type error
我尝试按照 Spring Data JPA with QueryDSL
中的教程进行操作
我的代码版本如下:
spring-boot = 1.3.8.release
查询-dsl = 3.7.4
我的实体如下
@Entity
@Table(name = BatchAPIEntity.TABLE)
public class BatchAPIEntity extends BatchEntity {
@JsonView(View.API.class)
@Column(name = KEY_NIT)
String nit;
}
我的存储库如下
public interface BatchApiRepository extends JpaRepository<BatchAPIEntity,Long>, QueryDslPredicateExecutor<BatchAPIEntity>{}
当我编译和构建代码时,显示以下错误
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type BatchAPIEntity!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:235)
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:373)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:353)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:84)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:62)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:100)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:211)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:74)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:416)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
... 47 common frames omitted
我的错误类似于以下问题中给出的错误,但问题是它没有答案
Error in findAll
我也试过这个答案,但没有任何好结果
我可以解决这个问题的方法是使用 QueryDslJpaRepository 而不是两个单独的接口,如下所示:
public interface BatchApiRepository extends QueryDslJpaRepository<BatchAPIEntity, Long>
我尝试按照 Spring Data JPA with QueryDSL
中的教程进行操作我的代码版本如下: spring-boot = 1.3.8.release 查询-dsl = 3.7.4
我的实体如下
@Entity
@Table(name = BatchAPIEntity.TABLE)
public class BatchAPIEntity extends BatchEntity {
@JsonView(View.API.class)
@Column(name = KEY_NIT)
String nit;
}
我的存储库如下
public interface BatchApiRepository extends JpaRepository<BatchAPIEntity,Long>, QueryDslPredicateExecutor<BatchAPIEntity>{}
当我编译和构建代码时,显示以下错误
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type BatchAPIEntity!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:235)
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:373)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:353)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:84)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:62)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:100)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:211)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:74)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:416)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
... 47 common frames omitted
我的错误类似于以下问题中给出的错误,但问题是它没有答案
Error in findAll
我也试过这个答案,但没有任何好结果
我可以解决这个问题的方法是使用 QueryDslJpaRepository 而不是两个单独的接口,如下所示:
public interface BatchApiRepository extends QueryDslJpaRepository<BatchAPIEntity, Long>