@Test @Sql(scripts = { "/sql/budgetdetail/clearBudgetDetail.sql", "/sql/budgetdetail/insertBudgetDetailData.sql" }) public void test_find_by_invalid_id_should_return_null() { BudgetDetailEntity budgetDetailEntity = BudgetDetailEntity.builder().id("5").build(); budgetDetailEntity.setTenantId("default"); BudgetDetailEntity result = budgetDetailJdbcRepository.findById(budgetDetailEntity); assertNull(result); }
public BudgetDetailEntity findById(final BudgetDetailEntity entity) { final List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); final Map<String, Object> paramValues = new HashMap<>(); for (final String s : list) paramValues.put(s, getValue(getField(entity, s), entity)); final List<BudgetDetailEntity> budgetdetails = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetDetailEntity.class)); if (budgetdetails.isEmpty()) return null; else return budgetdetails.get(0); }
BudgetDetailJdbcRepository extends JdbcRepository { public BudgetDetailEntity findById(final BudgetDetailEntity entity) { final List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); final Map<String, Object> paramValues = new HashMap<>(); for (final String s : list) paramValues.put(s, getValue(getField(entity, s), entity)); final List<BudgetDetailEntity> budgetdetails = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetDetailEntity.class)); if (budgetdetails.isEmpty()) return null; else return budgetdetails.get(0); } }
BudgetDetailJdbcRepository extends JdbcRepository { public BudgetDetailEntity findById(final BudgetDetailEntity entity) { final List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); final Map<String, Object> paramValues = new HashMap<>(); for (final String s : list) paramValues.put(s, getValue(getField(entity, s), entity)); final List<BudgetDetailEntity> budgetdetails = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetDetailEntity.class)); if (budgetdetails.isEmpty()) return null; else return budgetdetails.get(0); } BudgetDetailJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); }
BudgetDetailJdbcRepository extends JdbcRepository { public BudgetDetailEntity findById(final BudgetDetailEntity entity) { final List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); final Map<String, Object> paramValues = new HashMap<>(); for (final String s : list) paramValues.put(s, getValue(getField(entity, s), entity)); final List<BudgetDetailEntity> budgetdetails = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetDetailEntity.class)); if (budgetdetails.isEmpty()) return null; else return budgetdetails.get(0); } BudgetDetailJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); BudgetDetailEntity create(final BudgetDetailEntity entity); BudgetDetailEntity update(final BudgetDetailEntity entity); BudgetDetailEntity delete(final BudgetDetailEntity entity); Pagination<BudgetDetail> search(final BudgetDetailSearch domain); BudgetDetailEntity findById(final BudgetDetailEntity entity); }
BudgetDetailJdbcRepository extends JdbcRepository { public BudgetDetailEntity findById(final BudgetDetailEntity entity) { final List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); final Map<String, Object> paramValues = new HashMap<>(); for (final String s : list) paramValues.put(s, getValue(getField(entity, s), entity)); final List<BudgetDetailEntity> budgetdetails = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetDetailEntity.class)); if (budgetdetails.isEmpty()) return null; else return budgetdetails.get(0); } BudgetDetailJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, JdbcTemplate jdbcTemplate); BudgetDetailEntity create(final BudgetDetailEntity entity); BudgetDetailEntity update(final BudgetDetailEntity entity); BudgetDetailEntity delete(final BudgetDetailEntity entity); Pagination<BudgetDetail> search(final BudgetDetailSearch domain); BudgetDetailEntity findById(final BudgetDetailEntity entity);  }