コード例 #1
0
  @Override
  public Page<AccountTransferData> retrieveAll(final SearchParameters searchParameters) {

    final StringBuilder sqlBuilder = new StringBuilder(200);
    sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
    sqlBuilder.append(this.accountTransfersMapper.schema());

    if (searchParameters.isOrderByRequested()) {
      sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());

      if (searchParameters.isSortOrderProvided()) {
        sqlBuilder.append(' ').append(searchParameters.getSortOrder());
      }
    }

    if (searchParameters.isLimited()) {
      sqlBuilder.append(" limit ").append(searchParameters.getLimit());
      if (searchParameters.isOffset()) {
        sqlBuilder.append(" offset ").append(searchParameters.getOffset());
      }
    }

    final Object[] objectArray = new Object[2];
    final int arrayPos = 0;
    final Object[] finalObjectArray = Arrays.copyOf(objectArray, arrayPos);
    final String sqlCountRows = "SELECT FOUND_ROWS()";
    return this.paginationHelper.fetchPage(
        this.jdbcTemplate,
        sqlCountRows,
        sqlBuilder.toString(),
        finalObjectArray,
        this.accountTransfersMapper);
  }