gpt4 book ai didi

Spring Data 与 QueryDslPredicateExecutor 没有找到类型错误的属性 findAll

转载 作者:行者123 更新时间:2023-12-01 18:09:55 24 4
gpt4 key购买 nike

我尝试按照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

我也尝试了这个答案,但没有任何好的结果

https://stackoverflow.com/a/37800554/5192019

最佳答案

经过一番阅读后,我解决这个问题的方法是使用 QueryDslJpaRepository 而不是两个单独的接口(interface),如下所示:

public interface BatchApiRepository extends QueryDslJpaRepository<BatchAPIEntity, Long> 

关于Spring Data 与 QueryDslPredicateExecutor 没有找到类型错误的属性 findAll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39936455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com