class SurrenderReasonJdbcRepository extends JdbcRepository {

    public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) {
        SurrenderReasonSearchEntity surrenderReasonSearchEntity = new SurrenderReasonSearchEntity();
        surrenderReasonSearchEntity.toEntity(domain);

        String searchQuery = "select :selectfields from :tablename :condition  :orderby   ";

        Map<String, Object> paramValues = new HashMap<>();
        StringBuffer params = new StringBuffer();

        if (surrenderReasonSearchEntity.getSortBy() != null && !surrenderReasonSearchEntity.getSortBy().isEmpty()) {
            validateSortByOrder(surrenderReasonSearchEntity.getSortBy());
            validateEntityFieldName(surrenderReasonSearchEntity.getSortBy(), SurrenderReasonEntity.class);
        }

        String orderBy = "order by id";
        if (surrenderReasonSearchEntity.getSortBy() != null && !surrenderReasonSearchEntity.getSortBy().isEmpty())
            orderBy = "order by " + surrenderReasonSearchEntity.getSortBy();

        searchQuery = searchQuery.replace(":tablename", SurrenderReasonEntity.TABLE_NAME);

        searchQuery = searchQuery.replace(":selectfields", " * ");

        // implement jdbc specfic search
        if (surrenderReasonSearchEntity.getTenantId() != null) {
            if (params.length() > 0)
                params.append(" and ");
            params.append("tenantId =:tenantId");
            paramValues.put("tenantId", surrenderReasonSearchEntity.getTenantId());
        }
        if (surrenderReasonSearchEntity.getId() != null) {
            if (params.length() > 0)
                params.append(" and ");
            params.append("id =:id");
            paramValues.put("id", surrenderReasonSearchEntity.getId());
        }
        if (surrenderReasonSearchEntity.getName() != null) {
            if (params.length() > 0)
                params.append(" and ");
            params.append("name =:name");
            paramValues.put("name", surrenderReasonSearchEntity.getName());
        }
        if (surrenderReasonSearchEntity.getDescription() != null) {
            if (params.length() > 0)
                params.append(" and ");
            params.append("description =:description");
            paramValues.put("description", surrenderReasonSearchEntity.getDescription());
        }
        if (surrenderReasonSearchEntity.getIds() != null) {
            if (params.length() > 0)
                params.append(" and ");
            params.append("id in (:ids)");
            paramValues.put("ids", surrenderReasonSearchEntity.getIds());
        }

        Pagination<SurrenderReason> page = new Pagination<>();
        if (surrenderReasonSearchEntity.getOffset() != null)
            page.setOffset(surrenderReasonSearchEntity.getOffset());
        if (surrenderReasonSearchEntity.getPageSize() != null)
            page.setPageSize(surrenderReasonSearchEntity.getPageSize());

        if (params.length() > 0)
            searchQuery = searchQuery.replace(":condition", " where " + params.toString());
        else

            searchQuery = searchQuery.replace(":condition", "");

        searchQuery = searchQuery.replace(":orderby", orderBy);

        page = (Pagination<SurrenderReason>) getPagination(searchQuery, page, paramValues);
        searchQuery = searchQuery + " :pagination";

        searchQuery = searchQuery.replace(":pagination",
                "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize());

        BeanPropertyRowMapper row = new BeanPropertyRowMapper(SurrenderReasonEntity.class);

        List<SurrenderReasonEntity> surrenderReasonEntities = namedParameterJdbcTemplate.query(searchQuery.toString(),
                paramValues, row);

        page.setTotalResults(surrenderReasonEntities.size());

        List<SurrenderReason> surrenderreasons = new ArrayList<>();
        for (SurrenderReasonEntity surrenderReasonEntity : surrenderReasonEntities)
            surrenderreasons.add(surrenderReasonEntity.toDomain());
        page.setPagedData(surrenderreasons);

        return page;
    }

    public  SurrenderReasonJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate);

}