Announcement Announcement Module
Collapse
No announcement yet.
pageable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • pageable

    using spring-data-commons-core 1.0.0.BUILD-SNAPSHOT
    with spring-data-jpa 1.0.0.BUILD-SNAPSHOT

    data :
    Code:
    INSERT INTO User ( username, lastname) VALUES ( 'usr_1', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_2', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_3', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_4', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_5', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_6', 'Matthews');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_7', 'Beauford');
    INSERT INTO User ( username, lastname) VALUES ( 'usr_8', 'Lassard');
    test :
    Code:
    @BeforeTransaction
        public void setupData() throws Exception {
            if (countRowsInTable("User") == 0) {
                executeSqlScript("classpath:data.sql", false);
            }
            logger.info("rows:"+countRowsInTable("User"));
        }
    @Test
        public void testAllPages(){
        	Page<User> page = repository.findByLastname("Matthews", new PageRequest(0, 2));
        	logger.info(page);
        	logger.info(page.getContent());
        	while(page.hasNextPage()){
        		page = repository.findByLastname("Matthews", new PageRequest(page.getNumber()+1, 2));
        		logger.info(page);
        		logger.info(page.getContent());
        	}
        }
    result:
    Code:
    RepositoryTest - rows:8
    RepositoryTest - Page 0 of 4 containing org.wims.data.model.User instances
    RepositoryTest - [User[1:usr_1], User[2:usr_2]]
    RepositoryTest - Page 1 of 4 containing org.wims.data.model.User instances
    RepositoryTest - [User[3:usr_3], User[4:usr_4]]
    RepositoryTest - Page 2 of 4 containing org.wims.data.model.User instances
    RepositoryTest - [User[5:usr_5], User[6:usr_6]]
    RepositoryTest - Page 3 of 4 containing UNKNOWN instances
    RepositoryTest - []
    the count query does not use "findByLastname"

    could not find this problem in the issues

  • #2
    Good catch! Heres's the ticket [1] and the fix [2]. Deployed a snapshot so you should be able to go for now.

    Cheers,
    Ollie

    [1] https://jira.springsource.org/browse/DATAJPA-29
    [2] https://github.com/SpringSource/spri...2e5368d1c23870

    Comment


    • #3
      correct, thank you !

      Comment

      Working...
      X