@Test @Sql(scripts = { "/sql/budgetreappropriation/clearBudgetReAppropriation.sql", "/sql/budgetreappropriation/insertBudgetReAppropriationData.sql" }) public void test_invalid_search() { Pagination<BudgetReAppropriation> page = (Pagination<BudgetReAppropriation>) budgetReAppropriationJdbcRepository .search(getBudgetReAppropriationSearch1()); assertThat(page.getPagedData().size()).isEqualTo(0); }
public Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain) { final BudgetReAppropriationSearchEntity budgetReAppropriationSearchEntity = new BudgetReAppropriationSearchEntity(); budgetReAppropriationSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; final Map<String, Object> paramValues = new HashMap<>(); final StringBuffer params = new StringBuffer(); if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(budgetReAppropriationSearchEntity.getSortBy()); validateEntityFieldName(budgetReAppropriationSearchEntity.getSortBy(), BudgetEntity.class); } String orderBy = "order by id"; if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + budgetReAppropriationSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", BudgetReAppropriationEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (budgetReAppropriationSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", budgetReAppropriationSearchEntity.getTenantId()); } if (budgetReAppropriationSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", budgetReAppropriationSearchEntity.getId()); } if (budgetReAppropriationSearchEntity.getBudgetDetailId() != null) { if (params.length() > 0) params.append(" and "); params.append("budgetDetailid =:budgetDetail"); paramValues.put("budgetDetail", budgetReAppropriationSearchEntity.getBudgetDetailId()); } if (budgetReAppropriationSearchEntity.getAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("additionAmount =:additionAmount"); paramValues.put("additionAmount", budgetReAppropriationSearchEntity.getAdditionAmount()); } if (budgetReAppropriationSearchEntity.getDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("deductionAmount =:deductionAmount"); paramValues.put("deductionAmount", budgetReAppropriationSearchEntity.getDeductionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalAdditionAmount =:originalAdditionAmount"); paramValues.put("originalAdditionAmount", budgetReAppropriationSearchEntity.getOriginalAdditionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalDeductionAmount =:originalDeductionAmount"); paramValues.put("originalDeductionAmount", budgetReAppropriationSearchEntity.getOriginalDeductionAmount()); } if (budgetReAppropriationSearchEntity.getAnticipatoryAmount() != null && 0 != budgetReAppropriationSearchEntity.getAnticipatoryAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("anticipatoryAmount =:anticipatoryAmount"); paramValues.put("anticipatoryAmount", budgetReAppropriationSearchEntity.getAnticipatoryAmount()); } if (budgetReAppropriationSearchEntity.getStatusId() != null) { if (params.length() > 0) params.append(" and "); params.append("statusid =:status"); paramValues.put("status", budgetReAppropriationSearchEntity.getStatusId()); } if (budgetReAppropriationSearchEntity.getAsOnDate() != null) { if (params.length() > 0) params.append(" and "); params.append("asOnDate =:asOnDate"); paramValues.put("asOnDate", budgetReAppropriationSearchEntity.getAsOnDate()); } Pagination<BudgetReAppropriation> page = new Pagination<>(); if (budgetReAppropriationSearchEntity.getOffset() != null) page.setOffset(budgetReAppropriationSearchEntity.getOffset()); if (budgetReAppropriationSearchEntity.getPageSize() != null) page.setPageSize(budgetReAppropriationSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<BudgetReAppropriation>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); final BeanPropertyRowMapper row = new BeanPropertyRowMapper(BudgetReAppropriationEntity.class); final List<BudgetReAppropriationEntity> budgetReAppropriationEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(budgetReAppropriationEntities.size()); final List<BudgetReAppropriation> budgetreappropriations = new ArrayList<BudgetReAppropriation>(); for (final BudgetReAppropriationEntity budgetReAppropriationEntity : budgetReAppropriationEntities) budgetreappropriations.add(budgetReAppropriationEntity.toDomain()); page.setPagedData(budgetreappropriations); return page; }
BudgetReAppropriationJdbcRepository extends JdbcRepository { public Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain) { final BudgetReAppropriationSearchEntity budgetReAppropriationSearchEntity = new BudgetReAppropriationSearchEntity(); budgetReAppropriationSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; final Map<String, Object> paramValues = new HashMap<>(); final StringBuffer params = new StringBuffer(); if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(budgetReAppropriationSearchEntity.getSortBy()); validateEntityFieldName(budgetReAppropriationSearchEntity.getSortBy(), BudgetEntity.class); } String orderBy = "order by id"; if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + budgetReAppropriationSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", BudgetReAppropriationEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (budgetReAppropriationSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", budgetReAppropriationSearchEntity.getTenantId()); } if (budgetReAppropriationSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", budgetReAppropriationSearchEntity.getId()); } if (budgetReAppropriationSearchEntity.getBudgetDetailId() != null) { if (params.length() > 0) params.append(" and "); params.append("budgetDetailid =:budgetDetail"); paramValues.put("budgetDetail", budgetReAppropriationSearchEntity.getBudgetDetailId()); } if (budgetReAppropriationSearchEntity.getAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("additionAmount =:additionAmount"); paramValues.put("additionAmount", budgetReAppropriationSearchEntity.getAdditionAmount()); } if (budgetReAppropriationSearchEntity.getDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("deductionAmount =:deductionAmount"); paramValues.put("deductionAmount", budgetReAppropriationSearchEntity.getDeductionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalAdditionAmount =:originalAdditionAmount"); paramValues.put("originalAdditionAmount", budgetReAppropriationSearchEntity.getOriginalAdditionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalDeductionAmount =:originalDeductionAmount"); paramValues.put("originalDeductionAmount", budgetReAppropriationSearchEntity.getOriginalDeductionAmount()); } if (budgetReAppropriationSearchEntity.getAnticipatoryAmount() != null && 0 != budgetReAppropriationSearchEntity.getAnticipatoryAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("anticipatoryAmount =:anticipatoryAmount"); paramValues.put("anticipatoryAmount", budgetReAppropriationSearchEntity.getAnticipatoryAmount()); } if (budgetReAppropriationSearchEntity.getStatusId() != null) { if (params.length() > 0) params.append(" and "); params.append("statusid =:status"); paramValues.put("status", budgetReAppropriationSearchEntity.getStatusId()); } if (budgetReAppropriationSearchEntity.getAsOnDate() != null) { if (params.length() > 0) params.append(" and "); params.append("asOnDate =:asOnDate"); paramValues.put("asOnDate", budgetReAppropriationSearchEntity.getAsOnDate()); } Pagination<BudgetReAppropriation> page = new Pagination<>(); if (budgetReAppropriationSearchEntity.getOffset() != null) page.setOffset(budgetReAppropriationSearchEntity.getOffset()); if (budgetReAppropriationSearchEntity.getPageSize() != null) page.setPageSize(budgetReAppropriationSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<BudgetReAppropriation>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); final BeanPropertyRowMapper row = new BeanPropertyRowMapper(BudgetReAppropriationEntity.class); final List<BudgetReAppropriationEntity> budgetReAppropriationEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(budgetReAppropriationEntities.size()); final List<BudgetReAppropriation> budgetreappropriations = new ArrayList<BudgetReAppropriation>(); for (final BudgetReAppropriationEntity budgetReAppropriationEntity : budgetReAppropriationEntities) budgetreappropriations.add(budgetReAppropriationEntity.toDomain()); page.setPagedData(budgetreappropriations); return page; } }
BudgetReAppropriationJdbcRepository extends JdbcRepository { public Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain) { final BudgetReAppropriationSearchEntity budgetReAppropriationSearchEntity = new BudgetReAppropriationSearchEntity(); budgetReAppropriationSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; final Map<String, Object> paramValues = new HashMap<>(); final StringBuffer params = new StringBuffer(); if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(budgetReAppropriationSearchEntity.getSortBy()); validateEntityFieldName(budgetReAppropriationSearchEntity.getSortBy(), BudgetEntity.class); } String orderBy = "order by id"; if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + budgetReAppropriationSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", BudgetReAppropriationEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (budgetReAppropriationSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", budgetReAppropriationSearchEntity.getTenantId()); } if (budgetReAppropriationSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", budgetReAppropriationSearchEntity.getId()); } if (budgetReAppropriationSearchEntity.getBudgetDetailId() != null) { if (params.length() > 0) params.append(" and "); params.append("budgetDetailid =:budgetDetail"); paramValues.put("budgetDetail", budgetReAppropriationSearchEntity.getBudgetDetailId()); } if (budgetReAppropriationSearchEntity.getAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("additionAmount =:additionAmount"); paramValues.put("additionAmount", budgetReAppropriationSearchEntity.getAdditionAmount()); } if (budgetReAppropriationSearchEntity.getDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("deductionAmount =:deductionAmount"); paramValues.put("deductionAmount", budgetReAppropriationSearchEntity.getDeductionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalAdditionAmount =:originalAdditionAmount"); paramValues.put("originalAdditionAmount", budgetReAppropriationSearchEntity.getOriginalAdditionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalDeductionAmount =:originalDeductionAmount"); paramValues.put("originalDeductionAmount", budgetReAppropriationSearchEntity.getOriginalDeductionAmount()); } if (budgetReAppropriationSearchEntity.getAnticipatoryAmount() != null && 0 != budgetReAppropriationSearchEntity.getAnticipatoryAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("anticipatoryAmount =:anticipatoryAmount"); paramValues.put("anticipatoryAmount", budgetReAppropriationSearchEntity.getAnticipatoryAmount()); } if (budgetReAppropriationSearchEntity.getStatusId() != null) { if (params.length() > 0) params.append(" and "); params.append("statusid =:status"); paramValues.put("status", budgetReAppropriationSearchEntity.getStatusId()); } if (budgetReAppropriationSearchEntity.getAsOnDate() != null) { if (params.length() > 0) params.append(" and "); params.append("asOnDate =:asOnDate"); paramValues.put("asOnDate", budgetReAppropriationSearchEntity.getAsOnDate()); } Pagination<BudgetReAppropriation> page = new Pagination<>(); if (budgetReAppropriationSearchEntity.getOffset() != null) page.setOffset(budgetReAppropriationSearchEntity.getOffset()); if (budgetReAppropriationSearchEntity.getPageSize() != null) page.setPageSize(budgetReAppropriationSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<BudgetReAppropriation>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); final BeanPropertyRowMapper row = new BeanPropertyRowMapper(BudgetReAppropriationEntity.class); final List<BudgetReAppropriationEntity> budgetReAppropriationEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(budgetReAppropriationEntities.size()); final List<BudgetReAppropriation> budgetreappropriations = new ArrayList<BudgetReAppropriation>(); for (final BudgetReAppropriationEntity budgetReAppropriationEntity : budgetReAppropriationEntities) budgetreappropriations.add(budgetReAppropriationEntity.toDomain()); page.setPagedData(budgetreappropriations); return page; } BudgetReAppropriationJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); }
BudgetReAppropriationJdbcRepository extends JdbcRepository { public Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain) { final BudgetReAppropriationSearchEntity budgetReAppropriationSearchEntity = new BudgetReAppropriationSearchEntity(); budgetReAppropriationSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; final Map<String, Object> paramValues = new HashMap<>(); final StringBuffer params = new StringBuffer(); if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(budgetReAppropriationSearchEntity.getSortBy()); validateEntityFieldName(budgetReAppropriationSearchEntity.getSortBy(), BudgetEntity.class); } String orderBy = "order by id"; if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + budgetReAppropriationSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", BudgetReAppropriationEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (budgetReAppropriationSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", budgetReAppropriationSearchEntity.getTenantId()); } if (budgetReAppropriationSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", budgetReAppropriationSearchEntity.getId()); } if (budgetReAppropriationSearchEntity.getBudgetDetailId() != null) { if (params.length() > 0) params.append(" and "); params.append("budgetDetailid =:budgetDetail"); paramValues.put("budgetDetail", budgetReAppropriationSearchEntity.getBudgetDetailId()); } if (budgetReAppropriationSearchEntity.getAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("additionAmount =:additionAmount"); paramValues.put("additionAmount", budgetReAppropriationSearchEntity.getAdditionAmount()); } if (budgetReAppropriationSearchEntity.getDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("deductionAmount =:deductionAmount"); paramValues.put("deductionAmount", budgetReAppropriationSearchEntity.getDeductionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalAdditionAmount =:originalAdditionAmount"); paramValues.put("originalAdditionAmount", budgetReAppropriationSearchEntity.getOriginalAdditionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalDeductionAmount =:originalDeductionAmount"); paramValues.put("originalDeductionAmount", budgetReAppropriationSearchEntity.getOriginalDeductionAmount()); } if (budgetReAppropriationSearchEntity.getAnticipatoryAmount() != null && 0 != budgetReAppropriationSearchEntity.getAnticipatoryAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("anticipatoryAmount =:anticipatoryAmount"); paramValues.put("anticipatoryAmount", budgetReAppropriationSearchEntity.getAnticipatoryAmount()); } if (budgetReAppropriationSearchEntity.getStatusId() != null) { if (params.length() > 0) params.append(" and "); params.append("statusid =:status"); paramValues.put("status", budgetReAppropriationSearchEntity.getStatusId()); } if (budgetReAppropriationSearchEntity.getAsOnDate() != null) { if (params.length() > 0) params.append(" and "); params.append("asOnDate =:asOnDate"); paramValues.put("asOnDate", budgetReAppropriationSearchEntity.getAsOnDate()); } Pagination<BudgetReAppropriation> page = new Pagination<>(); if (budgetReAppropriationSearchEntity.getOffset() != null) page.setOffset(budgetReAppropriationSearchEntity.getOffset()); if (budgetReAppropriationSearchEntity.getPageSize() != null) page.setPageSize(budgetReAppropriationSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<BudgetReAppropriation>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); final BeanPropertyRowMapper row = new BeanPropertyRowMapper(BudgetReAppropriationEntity.class); final List<BudgetReAppropriationEntity> budgetReAppropriationEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(budgetReAppropriationEntities.size()); final List<BudgetReAppropriation> budgetreappropriations = new ArrayList<BudgetReAppropriation>(); for (final BudgetReAppropriationEntity budgetReAppropriationEntity : budgetReAppropriationEntities) budgetreappropriations.add(budgetReAppropriationEntity.toDomain()); page.setPagedData(budgetreappropriations); return page; } BudgetReAppropriationJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); BudgetReAppropriationEntity create(final BudgetReAppropriationEntity entity); BudgetReAppropriationEntity update(final BudgetReAppropriationEntity entity); BudgetReAppropriationEntity delete(final BudgetReAppropriationEntity entity); Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain); BudgetReAppropriationEntity findById(final BudgetReAppropriationEntity entity); }
BudgetReAppropriationJdbcRepository extends JdbcRepository { public Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain) { final BudgetReAppropriationSearchEntity budgetReAppropriationSearchEntity = new BudgetReAppropriationSearchEntity(); budgetReAppropriationSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; final Map<String, Object> paramValues = new HashMap<>(); final StringBuffer params = new StringBuffer(); if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(budgetReAppropriationSearchEntity.getSortBy()); validateEntityFieldName(budgetReAppropriationSearchEntity.getSortBy(), BudgetEntity.class); } String orderBy = "order by id"; if (budgetReAppropriationSearchEntity.getSortBy() != null && !budgetReAppropriationSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + budgetReAppropriationSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", BudgetReAppropriationEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (budgetReAppropriationSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", budgetReAppropriationSearchEntity.getTenantId()); } if (budgetReAppropriationSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", budgetReAppropriationSearchEntity.getId()); } if (budgetReAppropriationSearchEntity.getBudgetDetailId() != null) { if (params.length() > 0) params.append(" and "); params.append("budgetDetailid =:budgetDetail"); paramValues.put("budgetDetail", budgetReAppropriationSearchEntity.getBudgetDetailId()); } if (budgetReAppropriationSearchEntity.getAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("additionAmount =:additionAmount"); paramValues.put("additionAmount", budgetReAppropriationSearchEntity.getAdditionAmount()); } if (budgetReAppropriationSearchEntity.getDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("deductionAmount =:deductionAmount"); paramValues.put("deductionAmount", budgetReAppropriationSearchEntity.getDeductionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalAdditionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalAdditionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalAdditionAmount =:originalAdditionAmount"); paramValues.put("originalAdditionAmount", budgetReAppropriationSearchEntity.getOriginalAdditionAmount()); } if (budgetReAppropriationSearchEntity.getOriginalDeductionAmount() != null && 0 != budgetReAppropriationSearchEntity.getOriginalDeductionAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("originalDeductionAmount =:originalDeductionAmount"); paramValues.put("originalDeductionAmount", budgetReAppropriationSearchEntity.getOriginalDeductionAmount()); } if (budgetReAppropriationSearchEntity.getAnticipatoryAmount() != null && 0 != budgetReAppropriationSearchEntity.getAnticipatoryAmount().compareTo(BigDecimal.ZERO)) { if (params.length() > 0) params.append(" and "); params.append("anticipatoryAmount =:anticipatoryAmount"); paramValues.put("anticipatoryAmount", budgetReAppropriationSearchEntity.getAnticipatoryAmount()); } if (budgetReAppropriationSearchEntity.getStatusId() != null) { if (params.length() > 0) params.append(" and "); params.append("statusid =:status"); paramValues.put("status", budgetReAppropriationSearchEntity.getStatusId()); } if (budgetReAppropriationSearchEntity.getAsOnDate() != null) { if (params.length() > 0) params.append(" and "); params.append("asOnDate =:asOnDate"); paramValues.put("asOnDate", budgetReAppropriationSearchEntity.getAsOnDate()); } Pagination<BudgetReAppropriation> page = new Pagination<>(); if (budgetReAppropriationSearchEntity.getOffset() != null) page.setOffset(budgetReAppropriationSearchEntity.getOffset()); if (budgetReAppropriationSearchEntity.getPageSize() != null) page.setPageSize(budgetReAppropriationSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<BudgetReAppropriation>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); final BeanPropertyRowMapper row = new BeanPropertyRowMapper(BudgetReAppropriationEntity.class); final List<BudgetReAppropriationEntity> budgetReAppropriationEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(budgetReAppropriationEntities.size()); final List<BudgetReAppropriation> budgetreappropriations = new ArrayList<BudgetReAppropriation>(); for (final BudgetReAppropriationEntity budgetReAppropriationEntity : budgetReAppropriationEntities) budgetreappropriations.add(budgetReAppropriationEntity.toDomain()); page.setPagedData(budgetreappropriations); return page; } BudgetReAppropriationJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); BudgetReAppropriationEntity create(final BudgetReAppropriationEntity entity); BudgetReAppropriationEntity update(final BudgetReAppropriationEntity entity); BudgetReAppropriationEntity delete(final BudgetReAppropriationEntity entity); Pagination<BudgetReAppropriation> search(final BudgetReAppropriationSearch domain); BudgetReAppropriationEntity findById(final BudgetReAppropriationEntity entity);  }