使用QueryDslPredicateExecutor的Spring Data JPA方法findAll()与Predicate。

5

我遇到了这个错误:

我想使用一个方法,用QueryDslPredicateExecutor执行谓词搜索。 当该方法在我的服务实现上运行时,我收到了此错误:

16:59:44,165 DEBUG [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] (http-localhost-127.0.0.1-9090-4) Resolving exception from handler [public br.com.cleartech.itx.web.dto.PageDto br.com.cleartech.itx.web.controller.CngController.list(br.com.cleartech.itx.core.domain.Cng,org.springframework.data.domain.Pageable)]: org.springframework.data.mapping.PropertyReferenceException: No property cng found for type Cng!
16:59:44,167 DEBUG [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] (http-localhost-127.0.0.1-9090-4) Invoking @ExceptionHandler method: public org.springframework.web.servlet.ModelAndView br.com.cleartech.itx.web.exception.WebExceptionHandler.runtime(java.lang.Exception)
16:59:44,169 ERROR [br.com.cleartech.itx.web.exception.WebExceptionHandler] (http-localhost-127.0.0.1-9090-4) No property cng found for type Cng!
16:59:44,170 DEBUG [org.springframework.web.servlet.DispatcherServlet] (http-localhost-127.0.0.1-9090-4) Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'error'; model is {exception=org.springframework.data.mapping.PropertyReferenceException: No property cng found for type Cng!}: org.springframework.data.mapping.PropertyReferenceException: No property cng found for type Cng!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.jpa.repository.query.QueryUtils.toJpaOrder(QueryUtils.java:448) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at org.springframework.data.jpa.repository.query.QueryUtils.toOrders(QueryUtils.java:411) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:499) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:480) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:362) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_21]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:405) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:390) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:344) [spring-data-commons-1.8.5.RELEASE.jar:]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:119) [spring-data-jpa-1.6.5.RELEASE.jar:]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at com.sun.proxy.$Proxy126.findAll(Unknown Source)
    at br.com.cleartech.itx.core.service.impl.CngServiceImpl.search(CngServiceImpl.java:26) [itx-core-0.0.1-SNAPSHOT.jar:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_21]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) [spring-tx-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at com.sun.proxy.$Proxy127.search(Unknown Source)
    at br.com.cleartech.itx.web.controller.CngController.list(CngController.java:41) [classes:]
    at br.com.cleartech.itx.web.controller.CngController$$FastClassBySpringCGLIB$$48ccc37.invoke(<generated>) [spring-core-3.2.13.RELEASE.jar:]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64) [spring-security-core-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) [spring-aop-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at br.com.cleartech.itx.web.controller.CngController$$EnhancerBySpringCGLIB$$1abe0d77.list(<generated>) [spring-core-3.2.13.RELEASE.jar:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_21]
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) [spring-webmvc-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.2.6.RELEASE.jar:3.2.6.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final-RECOMPILE.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

以下是我的代码:

我的实体:

@Entity
@Table(name = "CNG")
public class Cng {
    @Id
    @SequenceGenerator(name = "SEQ_CNG", sequenceName = "SEQ_CNG", allocationSize = 1, initialValue= 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_CNG")
    @Column(name = "PK_ID_CNG") 
    private Long pkIdCng;

    @ManyToOne
    @JoinColumn(name = "FK_ID_OPERADORA", nullable = false)
    private Operadora operadora;

    @Column(name = "RN2")
    private String rn2;

    @Column(name = "NGEO")
    private String ngeo;

    @ManyToOne
    @JoinColumn(name = "FK_ID_PREFIXO", nullable = false)
    private Prefixo prefixo;

    @Column(name = "FAIXA_INICIAL")
    private String faixaInicial;

    @Column(name = "FAIXA_FINAL")
    private String faixaFinal;

    @Column(name = "INFO_SOLICITACAO")
    private String infoSolicitacao;

    @Column(name = "DT_CADASTRO")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private Timestamp dtCadastro;


    @Column(name = "FL_ATIVO", precision = 1, scale = 0, nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private TipoSituacao situacao;



    private static final QCng qCng = QCng.cng;
    /**
     * Cria um novo Predicate com propriedades diferente de null.
     * Create  a Predicate with not null properties.
     * @return {@link com.mysema.query.types.Predicate}
     */
    public Predicate toPredicate() {
        BooleanBuilder builder = new BooleanBuilder();

        if (pkIdCng!= null) {
            builder.and(qCng.pkIdCng.eq(pkIdCng));
        }

        if (operadora != null) {
            builder.and(qCng.operadora.cdEot.eq(operadora.getCdEot()));
        }


        if (rn2!= null) {
            builder.and(qCng.rn2.eq(rn2));
        }


        if (ngeo!= null) {
            builder.and(qCng.ngeo.eq(ngeo));
        }

        if (prefixo != null) {
            builder.and(qCng.prefixo.idPrefixo.eq(prefixo.getIdPrefixo()));
        }


        if (faixaInicial!= null) {
            builder.and(qCng.faixaInicial.eq(faixaInicial));
        }  


        if (faixaFinal!= null) {
            builder.and(qCng.faixaFinal.eq(faixaFinal));
        }


        if (infoSolicitacao!= null) {
            builder.and(qCng.infoSolicitacao.eq(infoSolicitacao));
        }

        if (dtCadastro != null) {
            builder.and(qCng.dtCadastro.loe(dtCadastro));
        }           

        builder.and(qCng.situacao.eq(TipoSituacao.ATIVO));

        return builder;
    }

    @Override
    public int hashCode() {

    }

    @Override
    public boolean equals(Object obj) {

    }



}

我的控制器:

public @ResponseBody PageDto list(@RequestBody Cng filtro, @PageableDefault(page = 1, size = 15) Pageable pageable) {
            List<Cng> items = new ArrayList<>();
            Page<Cng> page =  cngService.search(filtro.toPredicate(), pageable);
            if (!page.getContent().isEmpty()) {
                 items = page.getContent();
            }
            return ViewUtils.setPaging(items, page);
        }

我的服务实现:

@Service
public class CngServiceImpl implements CngService {

    @Autowired private CngRepository repository; 

    public Page<Cng> search(Predicate predicate, Pageable pageable) {
           Page<Cng> page = repository.findAll(predicate, pageable);
            return page;
    }    
}

我的仓库接口:

public interface CngRepository extends JpaRepository<Cng, Long>,
QueryDslPredicateExecutor<Cng>  {

 //...//
}

我不明白出了什么问题,请帮忙; 谢谢。


将您的服务方法标记为@transactional通常有效。 - ArunM
能否提供完整的堆栈跟踪信息? - Timo Westkämper
仍然无法使用@transactional。 - André Ribeiro
我尝试使用规范,但是出现了相同的错误。 - André Ribeiro
1个回答

4

从堆栈跟踪中可以看出,您正在将某种带有PageableSort对象传递到findAll(...)方法中。此排序表达式似乎以cgn开头。但是,您的类Cgn没有名为cgn的属性,这正是异常消息告诉您的。

org.springframework.data.mapping.PropertyReferenceException: No property cng found for type Cng!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接