@Test @Sql(scripts = { "/sql/instrumentaccountcode/clearInstrumentAccountCode.sql", "/sql/instrumentaccountcode/insertInstrumentAccountCodeData.sql" }) public void test_invalid_search() { Pagination<InstrumentAccountCode> page = (Pagination<InstrumentAccountCode>) instrumentAccountCodeJdbcRepository .search(getInstrumentAccountCodeSearch1()); assertThat(page.getPagedData().size()).isEqualTo(0); }
public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { InstrumentAccountCodeSearchEntity instrumentAccountCodeSearchEntity = new InstrumentAccountCodeSearchEntity(); instrumentAccountCodeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(instrumentAccountCodeSearchEntity.getSortBy()); validateEntityFieldName(instrumentAccountCodeSearchEntity.getSortBy(), InstrumentAccountCodeEntity.class); } String orderBy = "order by id"; if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + instrumentAccountCodeSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", InstrumentAccountCodeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (instrumentAccountCodeSearchEntity.getTenantId() != null) { if (params.length() > 0) params.append(" and "); params.append("tenantId =:tenantId"); paramValues.put("tenantId", instrumentAccountCodeSearchEntity.getTenantId()); } if (instrumentAccountCodeSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", instrumentAccountCodeSearchEntity.getId()); } if (instrumentAccountCodeSearchEntity.getInstrumentTypeId() != null) { if (params.length() > 0) params.append(" and "); params.append("instrumentTypeId =:instrumentType"); paramValues.put("instrumentType", instrumentAccountCodeSearchEntity.getInstrumentTypeId()); } if (instrumentAccountCodeSearchEntity.getAccountCodeId() != null) { if (params.length() > 0) params.append(" and "); params.append("accountCodeId =:accountCode"); paramValues.put("accountCode", instrumentAccountCodeSearchEntity.getAccountCodeId()); } if (instrumentAccountCodeSearchEntity.getIds() != null) { if (params.length() > 0) params.append(" and "); params.append("id in (:ids)"); paramValues.put("ids", instrumentAccountCodeSearchEntity.getIds()); } Pagination<InstrumentAccountCode> page = new Pagination<>(); if (instrumentAccountCodeSearchEntity.getOffset() != null) page.setOffset(instrumentAccountCodeSearchEntity.getOffset()); if (instrumentAccountCodeSearchEntity.getPageSize() != null) page.setPageSize(instrumentAccountCodeSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<InstrumentAccountCode>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(InstrumentAccountCodeEntity.class); List<InstrumentAccountCodeEntity> instrumentAccountCodeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(instrumentAccountCodeEntities.size()); List<InstrumentAccountCode> instrumentaccountcodes = new ArrayList<>(); for (InstrumentAccountCodeEntity instrumentAccountCodeEntity : instrumentAccountCodeEntities) instrumentaccountcodes.add(instrumentAccountCodeEntity.toDomain()); page.setPagedData(instrumentaccountcodes); return page; }
InstrumentAccountCodeJdbcRepository extends JdbcRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { InstrumentAccountCodeSearchEntity instrumentAccountCodeSearchEntity = new InstrumentAccountCodeSearchEntity(); instrumentAccountCodeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(instrumentAccountCodeSearchEntity.getSortBy()); validateEntityFieldName(instrumentAccountCodeSearchEntity.getSortBy(), InstrumentAccountCodeEntity.class); } String orderBy = "order by id"; if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + instrumentAccountCodeSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", InstrumentAccountCodeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (instrumentAccountCodeSearchEntity.getTenantId() != null) { if (params.length() > 0) params.append(" and "); params.append("tenantId =:tenantId"); paramValues.put("tenantId", instrumentAccountCodeSearchEntity.getTenantId()); } if (instrumentAccountCodeSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", instrumentAccountCodeSearchEntity.getId()); } if (instrumentAccountCodeSearchEntity.getInstrumentTypeId() != null) { if (params.length() > 0) params.append(" and "); params.append("instrumentTypeId =:instrumentType"); paramValues.put("instrumentType", instrumentAccountCodeSearchEntity.getInstrumentTypeId()); } if (instrumentAccountCodeSearchEntity.getAccountCodeId() != null) { if (params.length() > 0) params.append(" and "); params.append("accountCodeId =:accountCode"); paramValues.put("accountCode", instrumentAccountCodeSearchEntity.getAccountCodeId()); } if (instrumentAccountCodeSearchEntity.getIds() != null) { if (params.length() > 0) params.append(" and "); params.append("id in (:ids)"); paramValues.put("ids", instrumentAccountCodeSearchEntity.getIds()); } Pagination<InstrumentAccountCode> page = new Pagination<>(); if (instrumentAccountCodeSearchEntity.getOffset() != null) page.setOffset(instrumentAccountCodeSearchEntity.getOffset()); if (instrumentAccountCodeSearchEntity.getPageSize() != null) page.setPageSize(instrumentAccountCodeSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<InstrumentAccountCode>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(InstrumentAccountCodeEntity.class); List<InstrumentAccountCodeEntity> instrumentAccountCodeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(instrumentAccountCodeEntities.size()); List<InstrumentAccountCode> instrumentaccountcodes = new ArrayList<>(); for (InstrumentAccountCodeEntity instrumentAccountCodeEntity : instrumentAccountCodeEntities) instrumentaccountcodes.add(instrumentAccountCodeEntity.toDomain()); page.setPagedData(instrumentaccountcodes); return page; } }
InstrumentAccountCodeJdbcRepository extends JdbcRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { InstrumentAccountCodeSearchEntity instrumentAccountCodeSearchEntity = new InstrumentAccountCodeSearchEntity(); instrumentAccountCodeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(instrumentAccountCodeSearchEntity.getSortBy()); validateEntityFieldName(instrumentAccountCodeSearchEntity.getSortBy(), InstrumentAccountCodeEntity.class); } String orderBy = "order by id"; if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + instrumentAccountCodeSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", InstrumentAccountCodeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (instrumentAccountCodeSearchEntity.getTenantId() != null) { if (params.length() > 0) params.append(" and "); params.append("tenantId =:tenantId"); paramValues.put("tenantId", instrumentAccountCodeSearchEntity.getTenantId()); } if (instrumentAccountCodeSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", instrumentAccountCodeSearchEntity.getId()); } if (instrumentAccountCodeSearchEntity.getInstrumentTypeId() != null) { if (params.length() > 0) params.append(" and "); params.append("instrumentTypeId =:instrumentType"); paramValues.put("instrumentType", instrumentAccountCodeSearchEntity.getInstrumentTypeId()); } if (instrumentAccountCodeSearchEntity.getAccountCodeId() != null) { if (params.length() > 0) params.append(" and "); params.append("accountCodeId =:accountCode"); paramValues.put("accountCode", instrumentAccountCodeSearchEntity.getAccountCodeId()); } if (instrumentAccountCodeSearchEntity.getIds() != null) { if (params.length() > 0) params.append(" and "); params.append("id in (:ids)"); paramValues.put("ids", instrumentAccountCodeSearchEntity.getIds()); } Pagination<InstrumentAccountCode> page = new Pagination<>(); if (instrumentAccountCodeSearchEntity.getOffset() != null) page.setOffset(instrumentAccountCodeSearchEntity.getOffset()); if (instrumentAccountCodeSearchEntity.getPageSize() != null) page.setPageSize(instrumentAccountCodeSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<InstrumentAccountCode>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(InstrumentAccountCodeEntity.class); List<InstrumentAccountCodeEntity> instrumentAccountCodeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(instrumentAccountCodeEntities.size()); List<InstrumentAccountCode> instrumentaccountcodes = new ArrayList<>(); for (InstrumentAccountCodeEntity instrumentAccountCodeEntity : instrumentAccountCodeEntities) instrumentaccountcodes.add(instrumentAccountCodeEntity.toDomain()); page.setPagedData(instrumentaccountcodes); return page; } InstrumentAccountCodeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); }
InstrumentAccountCodeJdbcRepository extends JdbcRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { InstrumentAccountCodeSearchEntity instrumentAccountCodeSearchEntity = new InstrumentAccountCodeSearchEntity(); instrumentAccountCodeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(instrumentAccountCodeSearchEntity.getSortBy()); validateEntityFieldName(instrumentAccountCodeSearchEntity.getSortBy(), InstrumentAccountCodeEntity.class); } String orderBy = "order by id"; if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + instrumentAccountCodeSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", InstrumentAccountCodeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (instrumentAccountCodeSearchEntity.getTenantId() != null) { if (params.length() > 0) params.append(" and "); params.append("tenantId =:tenantId"); paramValues.put("tenantId", instrumentAccountCodeSearchEntity.getTenantId()); } if (instrumentAccountCodeSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", instrumentAccountCodeSearchEntity.getId()); } if (instrumentAccountCodeSearchEntity.getInstrumentTypeId() != null) { if (params.length() > 0) params.append(" and "); params.append("instrumentTypeId =:instrumentType"); paramValues.put("instrumentType", instrumentAccountCodeSearchEntity.getInstrumentTypeId()); } if (instrumentAccountCodeSearchEntity.getAccountCodeId() != null) { if (params.length() > 0) params.append(" and "); params.append("accountCodeId =:accountCode"); paramValues.put("accountCode", instrumentAccountCodeSearchEntity.getAccountCodeId()); } if (instrumentAccountCodeSearchEntity.getIds() != null) { if (params.length() > 0) params.append(" and "); params.append("id in (:ids)"); paramValues.put("ids", instrumentAccountCodeSearchEntity.getIds()); } Pagination<InstrumentAccountCode> page = new Pagination<>(); if (instrumentAccountCodeSearchEntity.getOffset() != null) page.setOffset(instrumentAccountCodeSearchEntity.getOffset()); if (instrumentAccountCodeSearchEntity.getPageSize() != null) page.setPageSize(instrumentAccountCodeSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<InstrumentAccountCode>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(InstrumentAccountCodeEntity.class); List<InstrumentAccountCodeEntity> instrumentAccountCodeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(instrumentAccountCodeEntities.size()); List<InstrumentAccountCode> instrumentaccountcodes = new ArrayList<>(); for (InstrumentAccountCodeEntity instrumentAccountCodeEntity : instrumentAccountCodeEntities) instrumentaccountcodes.add(instrumentAccountCodeEntity.toDomain()); page.setPagedData(instrumentaccountcodes); return page; } InstrumentAccountCodeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); InstrumentAccountCodeEntity create(InstrumentAccountCodeEntity entity); InstrumentAccountCodeEntity update(InstrumentAccountCodeEntity entity); InstrumentAccountCodeEntity delete(InstrumentAccountCodeEntity entity); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain); InstrumentAccountCodeEntity findById(InstrumentAccountCodeEntity entity); }
InstrumentAccountCodeJdbcRepository extends JdbcRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { InstrumentAccountCodeSearchEntity instrumentAccountCodeSearchEntity = new InstrumentAccountCodeSearchEntity(); instrumentAccountCodeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(instrumentAccountCodeSearchEntity.getSortBy()); validateEntityFieldName(instrumentAccountCodeSearchEntity.getSortBy(), InstrumentAccountCodeEntity.class); } String orderBy = "order by id"; if (instrumentAccountCodeSearchEntity.getSortBy() != null && !instrumentAccountCodeSearchEntity.getSortBy().isEmpty()) orderBy = "order by " + instrumentAccountCodeSearchEntity.getSortBy(); searchQuery = searchQuery.replace(":tablename", InstrumentAccountCodeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (instrumentAccountCodeSearchEntity.getTenantId() != null) { if (params.length() > 0) params.append(" and "); params.append("tenantId =:tenantId"); paramValues.put("tenantId", instrumentAccountCodeSearchEntity.getTenantId()); } if (instrumentAccountCodeSearchEntity.getId() != null) { if (params.length() > 0) params.append(" and "); params.append("id =:id"); paramValues.put("id", instrumentAccountCodeSearchEntity.getId()); } if (instrumentAccountCodeSearchEntity.getInstrumentTypeId() != null) { if (params.length() > 0) params.append(" and "); params.append("instrumentTypeId =:instrumentType"); paramValues.put("instrumentType", instrumentAccountCodeSearchEntity.getInstrumentTypeId()); } if (instrumentAccountCodeSearchEntity.getAccountCodeId() != null) { if (params.length() > 0) params.append(" and "); params.append("accountCodeId =:accountCode"); paramValues.put("accountCode", instrumentAccountCodeSearchEntity.getAccountCodeId()); } if (instrumentAccountCodeSearchEntity.getIds() != null) { if (params.length() > 0) params.append(" and "); params.append("id in (:ids)"); paramValues.put("ids", instrumentAccountCodeSearchEntity.getIds()); } Pagination<InstrumentAccountCode> page = new Pagination<>(); if (instrumentAccountCodeSearchEntity.getOffset() != null) page.setOffset(instrumentAccountCodeSearchEntity.getOffset()); if (instrumentAccountCodeSearchEntity.getPageSize() != null) page.setPageSize(instrumentAccountCodeSearchEntity.getPageSize()); if (params.length() > 0) searchQuery = searchQuery.replace(":condition", " where " + params.toString()); else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<InstrumentAccountCode>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(InstrumentAccountCodeEntity.class); List<InstrumentAccountCodeEntity> instrumentAccountCodeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(instrumentAccountCodeEntities.size()); List<InstrumentAccountCode> instrumentaccountcodes = new ArrayList<>(); for (InstrumentAccountCodeEntity instrumentAccountCodeEntity : instrumentAccountCodeEntities) instrumentaccountcodes.add(instrumentAccountCodeEntity.toDomain()); page.setPagedData(instrumentaccountcodes); return page; } InstrumentAccountCodeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); InstrumentAccountCodeEntity create(InstrumentAccountCodeEntity entity); InstrumentAccountCodeEntity update(InstrumentAccountCodeEntity entity); InstrumentAccountCodeEntity delete(InstrumentAccountCodeEntity entity); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain); InstrumentAccountCodeEntity findById(InstrumentAccountCodeEntity entity);  }