@Test @Sql(scripts = { "/sql/clearBankBranch.sql", "/sql/insertBankBranch.sql" }) public void testFindById() { BankBranchEntity bankBranchEntity = BankBranchEntity.builder().id("2").build(); bankBranchEntity.setTenantId("default"); BankBranchEntity result = bankBranchJdbcRepository.findById(bankBranchEntity); assertThat(result.getId()).isEqualTo("2"); assertThat(result.getName()).isEqualTo("name"); assertThat(result.getCode()).isEqualTo("code"); }
public BankBranchEntity findById(BankBranchEntity 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<BankBranchEntity> bankbranches = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankBranchEntity.class)); if (bankbranches.isEmpty()) { return null; } else { return bankbranches.get(0); } }
BankBranchJdbcRepository extends JdbcRepository { public BankBranchEntity findById(BankBranchEntity 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<BankBranchEntity> bankbranches = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankBranchEntity.class)); if (bankbranches.isEmpty()) { return null; } else { return bankbranches.get(0); } } }
BankBranchJdbcRepository extends JdbcRepository { public BankBranchEntity findById(BankBranchEntity 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<BankBranchEntity> bankbranches = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankBranchEntity.class)); if (bankbranches.isEmpty()) { return null; } else { return bankbranches.get(0); } } BankBranchJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
BankBranchJdbcRepository extends JdbcRepository { public BankBranchEntity findById(BankBranchEntity 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<BankBranchEntity> bankbranches = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankBranchEntity.class)); if (bankbranches.isEmpty()) { return null; } else { return bankbranches.get(0); } } BankBranchJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankBranchEntity create(BankBranchEntity entity); BankBranchEntity update(BankBranchEntity entity); Pagination<BankBranch> search(BankBranchSearch domain); BankBranchEntity findById(BankBranchEntity entity); }
BankBranchJdbcRepository extends JdbcRepository { public BankBranchEntity findById(BankBranchEntity 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<BankBranchEntity> bankbranches = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BankBranchEntity.class)); if (bankbranches.isEmpty()) { return null; } else { return bankbranches.get(0); } } BankBranchJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); BankBranchEntity create(BankBranchEntity entity); BankBranchEntity update(BankBranchEntity entity); Pagination<BankBranch> search(BankBranchSearch domain); BankBranchEntity findById(BankBranchEntity entity);  }