@Test @Sql(scripts = { "/sql/instrument/clearInstrument.sql", "/sql/instrument/insertInstrumentData.sql" }) public void test_find_by_id() { InstrumentEntity instrumentEntity = InstrumentEntity.builder().id("1").build(); instrumentEntity.setTenantId("default"); InstrumentEntity result = instrumentJdbcRepository.findById(instrumentEntity); assertThat(result.getAmount()).isEqualTo("1.00"); assertThat(result.getBankId()).isEqualTo("code"); assertThat(result.getBankAccountId()).isEqualTo("accountNumber"); assertThat(result.getBranchName()).isEqualTo("branchName"); assertThat(result.getDrawer()).isEqualTo("drawer"); assertThat(result.getFinancialStatusId()).isEqualTo("1"); assertThat(result.getInstrumentTypeId()).isEqualTo("name"); assertThat(result.getPayee()).isEqualTo("payee"); assertThat(result.getSerialNo()).isEqualTo("serialNo"); assertThat(result.getSurrenderReasonId()).isEqualTo("1"); assertThat(result.getTransactionNumber()).isEqualTo("transactionNumber"); assertThat(result.getTransactionType()).isEqualTo("Credit"); }
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);  }