Uploaded image for project: 'folio-spring-base'
  1. folio-spring-base
  2. FOLSPRINGB-72

Count Criteria Query does not work as expected

    XMLWordPrintable

Details

    • Spitfire Sprint 149
    • 3
    • Spitfire
    • Nolana (R3 2022)
    • Lack of testing

    Description

      After analyzing MODNOTES-244, it was noticed that the root cause of the bug is in the folio-spring-base module.
      toCountCriteria(String cql) method does not work as expected in Cql2JpaCriteria.class.

      Steps to Reproduce:
      To reproduce the bug just add below test to JpaCqlRepositoryTest.class and run this unit :

        @Test
        void testSelectAllRecordsWithLimit() {
          var page = personRepository.findByCQL("city.id==2", OffsetRequest.of(0, 1));
          assertThat(page)
            .hasSize(1);
        }
      

      Expected Results:
      The above unit test should pass and maybe need additional tests according to the implementation.

      Actual Results: throws this exception:

      Caused by: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias2,role=org.folio.spring.cql.domain.Person.city,tableName=city,tableAlias=city2_,origin=person person0_,columns={person0_.city_id,className=org.folio.spring.cql.domain.City}}] 
      [select count(generatedAlias0)
       from org.folio.spring.cql.domain.Person as generatedAlias0
       left join generatedAlias0.city as generatedAlias1
       inner join fetch generatedAlias0.city as generatedAlias2 where generatedAlias1.id=2]
      

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                sherzod_nurjonov Sherzod Nurjonov
                sherzod_nurjonov Sherzod Nurjonov
                Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases