@Test @Sql(scripts = { "/sql/clearAccountDetailType.sql", "/sql/insertAccountDetailType.sql" }) public void test_search_without_pagesize_offset_sortby() { AccountDetailTypeSearch search = getAccountDetailTypeSearch(); search.setSortBy(null); search.setPageSize(null); search.setOffset(null); Pagination<AccountDetailType> page = (Pagination<AccountDetailType>) accountDetailTypeJdbcRepository .search(getAccountDetailTypeSearch()); assertThat(page.getPagedData().get(0).getName()).isEqualTo("name"); assertThat(page.getPagedData().get(0).getActive()).isEqualTo(true); }
public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { AccountDetailTypeSearchEntity accountDetailTypeSearchEntity = new AccountDetailTypeSearchEntity(); accountDetailTypeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(accountDetailTypeSearchEntity.getSortBy()); validateEntityFieldName(accountDetailTypeSearchEntity.getSortBy(), AccountDetailTypeEntity.class); } String orderBy = "order by name"; if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { orderBy = "order by " + accountDetailTypeSearchEntity.getSortBy(); } searchQuery = searchQuery.replace(":tablename", AccountDetailTypeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (accountDetailTypeSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", accountDetailTypeSearchEntity.getTenantId()); } if (accountDetailTypeSearchEntity.getId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id =:id"); paramValues.put("id", accountDetailTypeSearchEntity.getId()); } if (accountDetailTypeSearchEntity.getIds() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id in(:ids) "); paramValues.put("ids", new ArrayList<String>(Arrays.asList(accountDetailTypeSearchEntity.getIds().split(",")))); } if (accountDetailTypeSearchEntity.getName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("name =:name"); paramValues.put("name", accountDetailTypeSearchEntity.getName()); } if (accountDetailTypeSearchEntity.getDescription() != null) { if (params.length() > 0) { params.append(" and "); } params.append("description =:description"); paramValues.put("description", accountDetailTypeSearchEntity.getDescription()); } if (accountDetailTypeSearchEntity.getTablename() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tableName =:tableName"); paramValues.put("tableName", accountDetailTypeSearchEntity.getTablename()); } if (accountDetailTypeSearchEntity.getActive() != null) { if (params.length() > 0) { params.append(" and "); } params.append("active =:active"); paramValues.put("active", accountDetailTypeSearchEntity.getActive()); } if (accountDetailTypeSearchEntity.getFullyQualifiedName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("fullyQualifiedName =:fullyQualifiedName"); paramValues.put("fullyQualifiedName", accountDetailTypeSearchEntity.getFullyQualifiedName()); } Pagination<AccountDetailType> page = new Pagination<>(); if (accountDetailTypeSearchEntity.getOffset() != null) { page.setOffset(accountDetailTypeSearchEntity.getOffset()); } if (accountDetailTypeSearchEntity.getPageSize() != null) { page.setPageSize(accountDetailTypeSearchEntity.getPageSize()); } if (params.length() > 0) { searchQuery = searchQuery.replace(":condition", " where " + params.toString()); } else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<AccountDetailType>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(AccountDetailTypeEntity.class); List<AccountDetailTypeEntity> accountDetailTypeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(accountDetailTypeEntities.size()); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); for (AccountDetailTypeEntity accountDetailTypeEntity : accountDetailTypeEntities) { accountdetailtypes.add(accountDetailTypeEntity.toDomain()); } page.setPagedData(accountdetailtypes); return page; }
AccountDetailTypeJdbcRepository extends JdbcRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { AccountDetailTypeSearchEntity accountDetailTypeSearchEntity = new AccountDetailTypeSearchEntity(); accountDetailTypeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(accountDetailTypeSearchEntity.getSortBy()); validateEntityFieldName(accountDetailTypeSearchEntity.getSortBy(), AccountDetailTypeEntity.class); } String orderBy = "order by name"; if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { orderBy = "order by " + accountDetailTypeSearchEntity.getSortBy(); } searchQuery = searchQuery.replace(":tablename", AccountDetailTypeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (accountDetailTypeSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", accountDetailTypeSearchEntity.getTenantId()); } if (accountDetailTypeSearchEntity.getId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id =:id"); paramValues.put("id", accountDetailTypeSearchEntity.getId()); } if (accountDetailTypeSearchEntity.getIds() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id in(:ids) "); paramValues.put("ids", new ArrayList<String>(Arrays.asList(accountDetailTypeSearchEntity.getIds().split(",")))); } if (accountDetailTypeSearchEntity.getName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("name =:name"); paramValues.put("name", accountDetailTypeSearchEntity.getName()); } if (accountDetailTypeSearchEntity.getDescription() != null) { if (params.length() > 0) { params.append(" and "); } params.append("description =:description"); paramValues.put("description", accountDetailTypeSearchEntity.getDescription()); } if (accountDetailTypeSearchEntity.getTablename() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tableName =:tableName"); paramValues.put("tableName", accountDetailTypeSearchEntity.getTablename()); } if (accountDetailTypeSearchEntity.getActive() != null) { if (params.length() > 0) { params.append(" and "); } params.append("active =:active"); paramValues.put("active", accountDetailTypeSearchEntity.getActive()); } if (accountDetailTypeSearchEntity.getFullyQualifiedName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("fullyQualifiedName =:fullyQualifiedName"); paramValues.put("fullyQualifiedName", accountDetailTypeSearchEntity.getFullyQualifiedName()); } Pagination<AccountDetailType> page = new Pagination<>(); if (accountDetailTypeSearchEntity.getOffset() != null) { page.setOffset(accountDetailTypeSearchEntity.getOffset()); } if (accountDetailTypeSearchEntity.getPageSize() != null) { page.setPageSize(accountDetailTypeSearchEntity.getPageSize()); } if (params.length() > 0) { searchQuery = searchQuery.replace(":condition", " where " + params.toString()); } else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<AccountDetailType>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(AccountDetailTypeEntity.class); List<AccountDetailTypeEntity> accountDetailTypeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(accountDetailTypeEntities.size()); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); for (AccountDetailTypeEntity accountDetailTypeEntity : accountDetailTypeEntities) { accountdetailtypes.add(accountDetailTypeEntity.toDomain()); } page.setPagedData(accountdetailtypes); return page; } }
AccountDetailTypeJdbcRepository extends JdbcRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { AccountDetailTypeSearchEntity accountDetailTypeSearchEntity = new AccountDetailTypeSearchEntity(); accountDetailTypeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(accountDetailTypeSearchEntity.getSortBy()); validateEntityFieldName(accountDetailTypeSearchEntity.getSortBy(), AccountDetailTypeEntity.class); } String orderBy = "order by name"; if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { orderBy = "order by " + accountDetailTypeSearchEntity.getSortBy(); } searchQuery = searchQuery.replace(":tablename", AccountDetailTypeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (accountDetailTypeSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", accountDetailTypeSearchEntity.getTenantId()); } if (accountDetailTypeSearchEntity.getId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id =:id"); paramValues.put("id", accountDetailTypeSearchEntity.getId()); } if (accountDetailTypeSearchEntity.getIds() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id in(:ids) "); paramValues.put("ids", new ArrayList<String>(Arrays.asList(accountDetailTypeSearchEntity.getIds().split(",")))); } if (accountDetailTypeSearchEntity.getName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("name =:name"); paramValues.put("name", accountDetailTypeSearchEntity.getName()); } if (accountDetailTypeSearchEntity.getDescription() != null) { if (params.length() > 0) { params.append(" and "); } params.append("description =:description"); paramValues.put("description", accountDetailTypeSearchEntity.getDescription()); } if (accountDetailTypeSearchEntity.getTablename() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tableName =:tableName"); paramValues.put("tableName", accountDetailTypeSearchEntity.getTablename()); } if (accountDetailTypeSearchEntity.getActive() != null) { if (params.length() > 0) { params.append(" and "); } params.append("active =:active"); paramValues.put("active", accountDetailTypeSearchEntity.getActive()); } if (accountDetailTypeSearchEntity.getFullyQualifiedName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("fullyQualifiedName =:fullyQualifiedName"); paramValues.put("fullyQualifiedName", accountDetailTypeSearchEntity.getFullyQualifiedName()); } Pagination<AccountDetailType> page = new Pagination<>(); if (accountDetailTypeSearchEntity.getOffset() != null) { page.setOffset(accountDetailTypeSearchEntity.getOffset()); } if (accountDetailTypeSearchEntity.getPageSize() != null) { page.setPageSize(accountDetailTypeSearchEntity.getPageSize()); } if (params.length() > 0) { searchQuery = searchQuery.replace(":condition", " where " + params.toString()); } else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<AccountDetailType>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(AccountDetailTypeEntity.class); List<AccountDetailTypeEntity> accountDetailTypeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(accountDetailTypeEntities.size()); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); for (AccountDetailTypeEntity accountDetailTypeEntity : accountDetailTypeEntities) { accountdetailtypes.add(accountDetailTypeEntity.toDomain()); } page.setPagedData(accountdetailtypes); return page; } AccountDetailTypeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
AccountDetailTypeJdbcRepository extends JdbcRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { AccountDetailTypeSearchEntity accountDetailTypeSearchEntity = new AccountDetailTypeSearchEntity(); accountDetailTypeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(accountDetailTypeSearchEntity.getSortBy()); validateEntityFieldName(accountDetailTypeSearchEntity.getSortBy(), AccountDetailTypeEntity.class); } String orderBy = "order by name"; if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { orderBy = "order by " + accountDetailTypeSearchEntity.getSortBy(); } searchQuery = searchQuery.replace(":tablename", AccountDetailTypeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (accountDetailTypeSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", accountDetailTypeSearchEntity.getTenantId()); } if (accountDetailTypeSearchEntity.getId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id =:id"); paramValues.put("id", accountDetailTypeSearchEntity.getId()); } if (accountDetailTypeSearchEntity.getIds() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id in(:ids) "); paramValues.put("ids", new ArrayList<String>(Arrays.asList(accountDetailTypeSearchEntity.getIds().split(",")))); } if (accountDetailTypeSearchEntity.getName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("name =:name"); paramValues.put("name", accountDetailTypeSearchEntity.getName()); } if (accountDetailTypeSearchEntity.getDescription() != null) { if (params.length() > 0) { params.append(" and "); } params.append("description =:description"); paramValues.put("description", accountDetailTypeSearchEntity.getDescription()); } if (accountDetailTypeSearchEntity.getTablename() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tableName =:tableName"); paramValues.put("tableName", accountDetailTypeSearchEntity.getTablename()); } if (accountDetailTypeSearchEntity.getActive() != null) { if (params.length() > 0) { params.append(" and "); } params.append("active =:active"); paramValues.put("active", accountDetailTypeSearchEntity.getActive()); } if (accountDetailTypeSearchEntity.getFullyQualifiedName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("fullyQualifiedName =:fullyQualifiedName"); paramValues.put("fullyQualifiedName", accountDetailTypeSearchEntity.getFullyQualifiedName()); } Pagination<AccountDetailType> page = new Pagination<>(); if (accountDetailTypeSearchEntity.getOffset() != null) { page.setOffset(accountDetailTypeSearchEntity.getOffset()); } if (accountDetailTypeSearchEntity.getPageSize() != null) { page.setPageSize(accountDetailTypeSearchEntity.getPageSize()); } if (params.length() > 0) { searchQuery = searchQuery.replace(":condition", " where " + params.toString()); } else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<AccountDetailType>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(AccountDetailTypeEntity.class); List<AccountDetailTypeEntity> accountDetailTypeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(accountDetailTypeEntities.size()); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); for (AccountDetailTypeEntity accountDetailTypeEntity : accountDetailTypeEntities) { accountdetailtypes.add(accountDetailTypeEntity.toDomain()); } page.setPagedData(accountdetailtypes); return page; } AccountDetailTypeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); AccountDetailTypeEntity create(AccountDetailTypeEntity entity); AccountDetailTypeEntity update(AccountDetailTypeEntity entity); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); AccountDetailTypeEntity findById(AccountDetailTypeEntity entity); }
AccountDetailTypeJdbcRepository extends JdbcRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { AccountDetailTypeSearchEntity accountDetailTypeSearchEntity = new AccountDetailTypeSearchEntity(); accountDetailTypeSearchEntity.toEntity(domain); String searchQuery = "select :selectfields from :tablename :condition :orderby "; Map<String, Object> paramValues = new HashMap<>(); StringBuffer params = new StringBuffer(); if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { validateSortByOrder(accountDetailTypeSearchEntity.getSortBy()); validateEntityFieldName(accountDetailTypeSearchEntity.getSortBy(), AccountDetailTypeEntity.class); } String orderBy = "order by name"; if (accountDetailTypeSearchEntity.getSortBy() != null && !accountDetailTypeSearchEntity.getSortBy().isEmpty()) { orderBy = "order by " + accountDetailTypeSearchEntity.getSortBy(); } searchQuery = searchQuery.replace(":tablename", AccountDetailTypeEntity.TABLE_NAME); searchQuery = searchQuery.replace(":selectfields", " * "); if (accountDetailTypeSearchEntity.getTenantId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tenantId =:tenantId"); paramValues.put("tenantId", accountDetailTypeSearchEntity.getTenantId()); } if (accountDetailTypeSearchEntity.getId() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id =:id"); paramValues.put("id", accountDetailTypeSearchEntity.getId()); } if (accountDetailTypeSearchEntity.getIds() != null) { if (params.length() > 0) { params.append(" and "); } params.append("id in(:ids) "); paramValues.put("ids", new ArrayList<String>(Arrays.asList(accountDetailTypeSearchEntity.getIds().split(",")))); } if (accountDetailTypeSearchEntity.getName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("name =:name"); paramValues.put("name", accountDetailTypeSearchEntity.getName()); } if (accountDetailTypeSearchEntity.getDescription() != null) { if (params.length() > 0) { params.append(" and "); } params.append("description =:description"); paramValues.put("description", accountDetailTypeSearchEntity.getDescription()); } if (accountDetailTypeSearchEntity.getTablename() != null) { if (params.length() > 0) { params.append(" and "); } params.append("tableName =:tableName"); paramValues.put("tableName", accountDetailTypeSearchEntity.getTablename()); } if (accountDetailTypeSearchEntity.getActive() != null) { if (params.length() > 0) { params.append(" and "); } params.append("active =:active"); paramValues.put("active", accountDetailTypeSearchEntity.getActive()); } if (accountDetailTypeSearchEntity.getFullyQualifiedName() != null) { if (params.length() > 0) { params.append(" and "); } params.append("fullyQualifiedName =:fullyQualifiedName"); paramValues.put("fullyQualifiedName", accountDetailTypeSearchEntity.getFullyQualifiedName()); } Pagination<AccountDetailType> page = new Pagination<>(); if (accountDetailTypeSearchEntity.getOffset() != null) { page.setOffset(accountDetailTypeSearchEntity.getOffset()); } if (accountDetailTypeSearchEntity.getPageSize() != null) { page.setPageSize(accountDetailTypeSearchEntity.getPageSize()); } if (params.length() > 0) { searchQuery = searchQuery.replace(":condition", " where " + params.toString()); } else searchQuery = searchQuery.replace(":condition", ""); searchQuery = searchQuery.replace(":orderby", orderBy); page = (Pagination<AccountDetailType>) getPagination(searchQuery, page, paramValues); searchQuery = searchQuery + " :pagination"; searchQuery = searchQuery.replace(":pagination", "limit " + page.getPageSize() + " offset " + page.getOffset() * page.getPageSize()); BeanPropertyRowMapper row = new BeanPropertyRowMapper(AccountDetailTypeEntity.class); List<AccountDetailTypeEntity> accountDetailTypeEntities = namedParameterJdbcTemplate .query(searchQuery.toString(), paramValues, row); page.setTotalResults(accountDetailTypeEntities.size()); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); for (AccountDetailTypeEntity accountDetailTypeEntity : accountDetailTypeEntities) { accountdetailtypes.add(accountDetailTypeEntity.toDomain()); } page.setPagedData(accountdetailtypes); return page; } AccountDetailTypeJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); AccountDetailTypeEntity create(AccountDetailTypeEntity entity); AccountDetailTypeEntity update(AccountDetailTypeEntity entity); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); AccountDetailTypeEntity findById(AccountDetailTypeEntity entity);  }