@Test @Sql(scripts = { "/sql/clearBank.sql", "/sql/insertBank.sql" }) public void testFindById() { BankEntity bankEntity = BankEntity.builder().id("2").build(); bankEntity.setTenantId("default"); BankEntity result = bankJdbcRepository.findById(bankEntity); assertThat(result.getId()).isEqualTo("2"); assertThat(result.getName()).isEqualTo("name"); assertThat(result.getCode()).isEqualTo("code"); }
public BankEntity findById(BankEntity 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<BankEntity> banks = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankEntity.class)); if (banks.isEmpty()) { return null; } else { return banks.get(0); } }
BankJdbcRepository extends JdbcRepository { public BankEntity findById(BankEntity 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<BankEntity> banks = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankEntity.class)); if (banks.isEmpty()) { return null; } else { return banks.get(0); } } }
BankJdbcRepository extends JdbcRepository { public BankEntity findById(BankEntity 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<BankEntity> banks = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankEntity.class)); if (banks.isEmpty()) { return null; } else { return banks.get(0); } } BankJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
BankJdbcRepository extends JdbcRepository { public BankEntity findById(BankEntity 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<BankEntity> banks = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankEntity.class)); if (banks.isEmpty()) { return null; } else { return banks.get(0); } } BankJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankEntity create(BankEntity entity); BankEntity update(BankEntity entity); Pagination<Bank> search(BankSearch domain); BankEntity findById(BankEntity entity); }
BankJdbcRepository extends JdbcRepository { public BankEntity findById(BankEntity 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<BankEntity> banks = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankEntity.class)); if (banks.isEmpty()) { return null; } else { return banks.get(0); } } BankJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankEntity create(BankEntity entity); BankEntity update(BankEntity entity); Pagination<Bank> search(BankSearch domain); BankEntity findById(BankEntity entity);  }