@Test @Sql(scripts = { "/sql/clearBankAccount.sql", "/sql/insertBankAccount.sql" }) public void test_find_by_invalid_id_should_return_null() { BankAccountEntity bankAccountEntity = BankAccountEntity.builder().id("5").build(); bankAccountEntity.setTenantId("default"); BankAccountEntity result = bankAccountJdbcRepository.findById(bankAccountEntity); assertNull(result); }
public BankAccountEntity findById(BankAccountEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<BankAccountEntity> bankaccounts = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankAccountEntity.class)); if (bankaccounts.isEmpty()) { return null; } else { return bankaccounts.get(0); } }
BankAccountJdbcRepository extends JdbcRepository { public BankAccountEntity findById(BankAccountEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<BankAccountEntity> bankaccounts = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankAccountEntity.class)); if (bankaccounts.isEmpty()) { return null; } else { return bankaccounts.get(0); } } }
BankAccountJdbcRepository extends JdbcRepository { public BankAccountEntity findById(BankAccountEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<BankAccountEntity> bankaccounts = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankAccountEntity.class)); if (bankaccounts.isEmpty()) { return null; } else { return bankaccounts.get(0); } } BankAccountJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
BankAccountJdbcRepository extends JdbcRepository { public BankAccountEntity findById(BankAccountEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<BankAccountEntity> bankaccounts = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankAccountEntity.class)); if (bankaccounts.isEmpty()) { return null; } else { return bankaccounts.get(0); } } BankAccountJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankAccountEntity create(BankAccountEntity entity); BankAccountEntity update(BankAccountEntity entity); Pagination<BankAccount> search(BankAccountSearch domain); BankAccountEntity findById(BankAccountEntity entity); }
BankAccountJdbcRepository extends JdbcRepository { public BankAccountEntity findById(BankAccountEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<BankAccountEntity> bankaccounts = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankAccountEntity.class)); if (bankaccounts.isEmpty()) { return null; } else { return bankaccounts.get(0); } } BankAccountJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankAccountEntity create(BankAccountEntity entity); BankAccountEntity update(BankAccountEntity entity); Pagination<BankAccount> search(BankAccountSearch domain); BankAccountEntity findById(BankAccountEntity entity);  }