@Test @Sql(scripts = { "/sql/clearFund.sql", "/sql/insertFundData.sql" }) public void test_find_by_id() { FundEntity fundEntity = FundEntity.builder().id("2").build(); fundEntity.setTenantId("default"); FundEntity result = fundJdbcRepository.findById(fundEntity); assertThat(result.getId()).isEqualTo("2"); assertThat(result.getName()).isEqualTo("name"); assertThat(result.getCode()).isEqualTo("code"); }
public FundEntity findById(FundEntity 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<FundEntity> funds = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FundEntity.class)); if (funds.isEmpty()) { return null; } else { return funds.get(0); } }
FundJdbcRepository extends JdbcRepository { public FundEntity findById(FundEntity 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<FundEntity> funds = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FundEntity.class)); if (funds.isEmpty()) { return null; } else { return funds.get(0); } } }
FundJdbcRepository extends JdbcRepository { public FundEntity findById(FundEntity 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<FundEntity> funds = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FundEntity.class)); if (funds.isEmpty()) { return null; } else { return funds.get(0); } } FundJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
FundJdbcRepository extends JdbcRepository { public FundEntity findById(FundEntity 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<FundEntity> funds = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FundEntity.class)); if (funds.isEmpty()) { return null; } else { return funds.get(0); } } FundJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); FundEntity create(FundEntity entity); FundEntity update(FundEntity entity); boolean delete(FundEntity entity,String reason); Pagination<Fund> search(FundSearch domain); FundEntity findById(FundEntity entity); }
FundJdbcRepository extends JdbcRepository { public FundEntity findById(FundEntity 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<FundEntity> funds = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FundEntity.class)); if (funds.isEmpty()) { return null; } else { return funds.get(0); } } FundJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); FundEntity create(FundEntity entity); FundEntity update(FundEntity entity); boolean delete(FundEntity entity,String reason); Pagination<Fund> search(FundSearch domain); FundEntity findById(FundEntity entity);  }