• <bdo id='uHFjW'></bdo><ul id='uHFjW'></ul>
  • <i id='uHFjW'><tr id='uHFjW'><dt id='uHFjW'><q id='uHFjW'><span id='uHFjW'><b id='uHFjW'><form id='uHFjW'><ins id='uHFjW'></ins><ul id='uHFjW'></ul><sub id='uHFjW'></sub></form><legend id='uHFjW'></legend><bdo id='uHFjW'><pre id='uHFjW'><center id='uHFjW'></center></pre></bdo></b><th id='uHFjW'></th></span></q></dt></tr></i><div id='uHFjW'><tfoot id='uHFjW'></tfoot><dl id='uHFjW'><fieldset id='uHFjW'></fieldset></dl></div>

    <small id='uHFjW'></small><noframes id='uHFjW'>

  • <legend id='uHFjW'><style id='uHFjW'><dir id='uHFjW'><q id='uHFjW'></q></dir></style></legend>

        <tfoot id='uHFjW'></tfoot>

        弹簧规范和可分页

        时间:2024-08-23
          <tbody id='oI0Ss'></tbody>

      1. <i id='oI0Ss'><tr id='oI0Ss'><dt id='oI0Ss'><q id='oI0Ss'><span id='oI0Ss'><b id='oI0Ss'><form id='oI0Ss'><ins id='oI0Ss'></ins><ul id='oI0Ss'></ul><sub id='oI0Ss'></sub></form><legend id='oI0Ss'></legend><bdo id='oI0Ss'><pre id='oI0Ss'><center id='oI0Ss'></center></pre></bdo></b><th id='oI0Ss'></th></span></q></dt></tr></i><div id='oI0Ss'><tfoot id='oI0Ss'></tfoot><dl id='oI0Ss'><fieldset id='oI0Ss'></fieldset></dl></div>

        1. <tfoot id='oI0Ss'></tfoot>

          • <legend id='oI0Ss'><style id='oI0Ss'><dir id='oI0Ss'><q id='oI0Ss'></q></dir></style></legend>

            • <bdo id='oI0Ss'></bdo><ul id='oI0Ss'></ul>

                  <small id='oI0Ss'></small><noframes id='oI0Ss'>

                • 本文介绍了弹簧规范和可分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  SpecificationPageable如何一起使用?

                  personelRepository.java

                  @Query("SELECT e FROM PersonelEntity e ")
                  List<PersonelEntity> findData(Specification<PersonelEntity>  test, Pageable pageable);
                  

                  personelService.java

                  public List<PersonelEntity> filteredData(Specification<PersonelEntity> filter,Pageable  pageable){
                      List<PersonelEntity> filteredData = personelRepository.findData(filter,pageable);
                      return filteredData;
                  }
                  

                  personelController.java

                  Pageable reqCount = new PageRequest(0, 10);
                  Specification<PersonelEntity> filter = new FilterSpecification<PersonelEntity>(new SearchCriteria("name", "=","lux"));
                  personels = personelService.findData(filter,reqCount);
                  

                  当我运行它时,我会收到这样的错误.但是,如果我像 findAll(Pageable page) 和 findAll(Specification filter) 那样分别调用 findAll() 函数,它就可以工作.但是不能一起用.

                  When I run it I get an error like this. But if I call findAll() function separately like findAll(Pageable page) and findAll(Specification filter) it works. But I can not use it together.

                  java.lang.IllegalArgumentException: Parameter with that position [1] did not exist
                      at org.hibernate.jpa.spi.BaseQueryImpl.findParameterRegistration(BaseQueryImpl.java:502) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
                      at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:692) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
                      at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:181) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
                      at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:32) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
                      at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:141) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.StringQueryParameterBinder.bind(StringQueryParameterBinder.java:61) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:101) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.bind(SpelExpressionStringQueryParameterBinder.java:69) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:161) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:152) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:81) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:190) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:121) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                      at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:85) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
                  

                  推荐答案

                  编辑personelService.java,删除personelRepository上的findData函数解决.我使用 springframework.data.jpa.repository.JpaRepository findAll() 函数并且它有效.

                  Solve by editing personelService.java and delete findData function on personelRepository. I use springframework.data.jpa.repository.JpaRepository findAll() function and it works.

                  public List<PersonelEntity> filteredData (Specification<PersonelEntity> spec, Pageable pageable){
                      Page<PersonelEntity> pageData = personelRepository.findAll(spec,pageable);
                      List<PersonelEntity> filteredData = pageData.getContent();
                      return filteredData;
                  }
                  

                  这篇关于弹簧规范和可分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用 java config 而不是 XML 声明一个存储库填充器 bean? 下一篇:如何在 Spring Data MongoDB 中使用乐观锁定?

                  相关文章

                  <i id='Yj26i'><tr id='Yj26i'><dt id='Yj26i'><q id='Yj26i'><span id='Yj26i'><b id='Yj26i'><form id='Yj26i'><ins id='Yj26i'></ins><ul id='Yj26i'></ul><sub id='Yj26i'></sub></form><legend id='Yj26i'></legend><bdo id='Yj26i'><pre id='Yj26i'><center id='Yj26i'></center></pre></bdo></b><th id='Yj26i'></th></span></q></dt></tr></i><div id='Yj26i'><tfoot id='Yj26i'></tfoot><dl id='Yj26i'><fieldset id='Yj26i'></fieldset></dl></div>

                    <small id='Yj26i'></small><noframes id='Yj26i'>

                    1. <legend id='Yj26i'><style id='Yj26i'><dir id='Yj26i'><q id='Yj26i'></q></dir></style></legend>
                        <bdo id='Yj26i'></bdo><ul id='Yj26i'></ul>
                    2. <tfoot id='Yj26i'></tfoot>