title: Limit number of total records that a JdbcPagingItemReader can read in a Spring Batch project
body: <p>I am trying to read a database table that has millions of records and I am using JdbcPagingItemReader for that reason.</p>
  
  <p>However, I am at the testing phase for now and I am trying to limit number of total records that I can read using <code>JdbcPagingItemReader</code>.
  I know this should be simple, its just hiding somewhere.</p>
  
  <p>This is how my reader looks like:</p>
  
  <pre><code>   @Bean (name = "metadataItemReader")
     public ItemReader&lt;DocumentMetadata&gt; itemReader( @Value( "${count}" ) int count ) {
  
        JdbcPagingItemReader&lt;DocumentMetadata&gt; reader = new JdbcPagingItemReader&lt;&gt;();
        final SqlPagingQueryProviderFactoryBean sqlPagingQueryProviderFactoryBean = new SqlPagingQueryProviderFactoryBean();
        sqlPagingQueryProviderFactoryBean.setDataSource(dataSource);
        sqlPagingQueryProviderFactoryBean.setSelectClause("select id, file_path, file_name, extension, created_by, TO_CHAR(create_date, 'yyyy-mm-dd hh24:mi:ss') as create_date");
        sqlPagingQueryProviderFactoryBean.setFromClause("from document_metadata");
        //sqlPagingQueryProviderFactoryBean.l
        sqlPagingQueryProviderFactoryBean.setSortKey("id");
        try {
           reader.setQueryProvider(sqlPagingQueryProviderFactoryBean.getObject());
        } catch (Exception e) {
           log.error(e.getMessage());
        }
        reader.setDataSource(dataSource);
        reader.setPageSize(10);
        reader.setRowMapper( new MetadataRowMapper() );
        return reader;
     }
  </code></pre>