@Test @Sql(scripts = { "/sql/budget/clearBudget.sql", "/sql/budget/insertBudgetData.sql" }) public void test_find_by_id() { BudgetEntity budgetEntity = BudgetEntity.builder().id("1").build(); budgetEntity.setTenantId("default"); BudgetEntity result = budgetJdbcRepository.findById(budgetEntity); assertThat(result.getId()).isEqualTo("1"); assertThat(result.getName()).isEqualTo("name"); }
public BudgetEntity findById(final BudgetEntity 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<BudgetEntity> budgets = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetEntity.class)); if (budgets.isEmpty()) return null; else return budgets.get(0); }
BudgetJdbcRepository extends JdbcRepository { public BudgetEntity findById(final BudgetEntity 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<BudgetEntity> budgets = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetEntity.class)); if (budgets.isEmpty()) return null; else return budgets.get(0); } }
BudgetJdbcRepository extends JdbcRepository { public BudgetEntity findById(final BudgetEntity 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<BudgetEntity> budgets = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetEntity.class)); if (budgets.isEmpty()) return null; else return budgets.get(0); } BudgetJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, final JdbcTemplate jdbcTemplate); }
BudgetJdbcRepository extends JdbcRepository { public BudgetEntity findById(final BudgetEntity 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<BudgetEntity> budgets = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetEntity.class)); if (budgets.isEmpty()) return null; else return budgets.get(0); } BudgetJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, final JdbcTemplate jdbcTemplate); BudgetEntity create(final BudgetEntity entity); BudgetEntity update(final BudgetEntity entity); BudgetEntity delete(final BudgetEntity entity); Pagination<Budget> search(final BudgetSearch domain); BudgetEntity findById(final BudgetEntity entity); }
BudgetJdbcRepository extends JdbcRepository { public BudgetEntity findById(final BudgetEntity 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<BudgetEntity> budgets = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(BudgetEntity.class)); if (budgets.isEmpty()) return null; else return budgets.get(0); } BudgetJdbcRepository(final NamedParameterJdbcTemplate namedParameterJdbcTemplate, final JdbcTemplate jdbcTemplate); BudgetEntity create(final BudgetEntity entity); BudgetEntity update(final BudgetEntity entity); BudgetEntity delete(final BudgetEntity entity); Pagination<Budget> search(final BudgetSearch domain); BudgetEntity findById(final BudgetEntity entity);  }