public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception { // Get the CreativeService. CreativeServiceInterface creativeService = dfpServices.get(session, CreativeServiceInterface.class); // Create a statement to only select image creatives. StatementBuilder statementBuilder = new StatementBuilder() .where("creativeType = :creativeType") .orderBy("id ASC") .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .withBindVariableValue("creativeType", ImageCreative.class.getSimpleName()); // Default for total result set size. int totalResultSetSize = 0; do { // Get creatives by statement. CreativePage page = creativeService.getCreativesByStatement(statementBuilder.toStatement()); if (page.getResults() != null) { totalResultSetSize = page.getTotalResultSetSize(); int i = page.getStartIndex(); for (Creative creative : page.getResults()) { System.out.printf( "%d) Creative with ID \"%d\" and name \"%s\" was found.\n", i++, creative.getId(), creative.getName()); } } statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.getOffset() < totalResultSetSize); System.out.printf("Number of results found: %d\n", totalResultSetSize); }