Uploaded image for project: 'Spring Data for Apache Cassandra'
  1. Spring Data for Apache Cassandra
  2. DATACASS-763

Cassandra Spring Data Apache CassandraOperations slice hasNext is not giving Proper result

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core, Repository, Template API
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Spring Boot Version2.1.6.RELEASE

      Spring Data Cassandra : 2.1.9.RELEASE

      Cassandra Driver : 3.6.0

       

      Issue : template.Slice method hasNext() returns true if data is in even records

      Description :  I am using CassandraOperations  class to query the slice object for pagination purpose . Below is my snippet 

       

      Case 1: Suppose say total  User records 6 then result.hasNext() will be true since FetchSize is divisible by total result (6/3)==> This will not work as excepted

      Case 2: Suppose say total  User records 7 then result.hasNext() will be false since FetchSize is divisible by total result (7/3) ==> This works fine

      #Preparing the Query##

       

      @Autowired private CassandraOperations template;
      
      Select select = QueryBuilder.select().all()
       .from("user");
       select.setFetchSize("3");
      if (pagingState != null && !pagingState.isEmpty()) {
       try {
       select.setPagingState(PagingState.fromString(pagingState));
       } catch (PagingStateException ex) {
       throw new PagingStateException("Page is invalid");
       }
       }
      Slice<User> result = template.slice(select, User.class);
       String nextUrl = "";
       if (result.hasNext()) {
       nextUrl = getNextUri(next.getPagingState().toString());
       }
      

       

      Why result.hasNext() is works weird,As per my Understanding hasNext should return false if there is no records in next result set , case 1 and case 2 both should return false

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              panditb Pandit Biradar
              Last updater:
              Pandit Biradar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                19 weeks, 4 days ago