@Test @Sql(scripts = { "/sql/instrument/clearInstrument.sql", "/sql/instrument/insertInstrumentData.sql" }) public void test_find_by_invalid_id_should_return_null() { InstrumentEntity instrumentEntity = InstrumentEntity.builder().id("5").build(); instrumentEntity.setTenantId("default"); InstrumentEntity result = instrumentJdbcRepository.findById(instrumentEntity); assertNull(result); }
public InstrumentEntity findById(InstrumentEntity 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<InstrumentEntity> instruments = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(InstrumentEntity.class)); if (instruments.isEmpty()) return null; else return instruments.get(0); }
InstrumentJdbcRepository extends JdbcRepository { public InstrumentEntity findById(InstrumentEntity 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<InstrumentEntity> instruments = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(InstrumentEntity.class)); if (instruments.isEmpty()) return null; else return instruments.get(0); } }
InstrumentJdbcRepository extends JdbcRepository { public InstrumentEntity findById(InstrumentEntity 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<InstrumentEntity> instruments = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(InstrumentEntity.class)); if (instruments.isEmpty()) return null; else return instruments.get(0); } InstrumentJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); }
InstrumentJdbcRepository extends JdbcRepository { public InstrumentEntity findById(InstrumentEntity 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<InstrumentEntity> instruments = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(InstrumentEntity.class)); if (instruments.isEmpty()) return null; else return instruments.get(0); } InstrumentJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); InstrumentEntity create(InstrumentEntity entity); InstrumentEntity update(InstrumentEntity entity); InstrumentEntity delete(InstrumentEntity entity); Pagination<Instrument> search(InstrumentSearch domain); InstrumentEntity findById(InstrumentEntity entity); }
InstrumentJdbcRepository extends JdbcRepository { public InstrumentEntity findById(InstrumentEntity 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<InstrumentEntity> instruments = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(InstrumentEntity.class)); if (instruments.isEmpty()) return null; else return instruments.get(0); } InstrumentJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); InstrumentEntity create(InstrumentEntity entity); InstrumentEntity update(InstrumentEntity entity); InstrumentEntity delete(InstrumentEntity entity); Pagination<Instrument> search(InstrumentSearch domain); InstrumentEntity findById(InstrumentEntity entity);  }