@Test @Sql(scripts = { "/sql/clearFunction.sql", "/sql/insertFunctionData.sql" }) public void test_find_by_id() { FunctionEntity functionEntity = FunctionEntity.builder().id("2").build(); functionEntity.setTenantId("default"); FunctionEntity result = functionJdbcRepository.findById(functionEntity); assertThat(result.getId()).isEqualTo("2"); assertThat(result.getName()).isEqualTo("name"); assertThat(result.getCode()).isEqualTo("code"); }
public FunctionEntity findById(FunctionEntity 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<FunctionEntity> functions = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FunctionEntity.class)); if (functions.isEmpty()) { return null; } else { return functions.get(0); } }
FunctionJdbcRepository extends JdbcRepository { public FunctionEntity findById(FunctionEntity 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<FunctionEntity> functions = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FunctionEntity.class)); if (functions.isEmpty()) { return null; } else { return functions.get(0); } } }
FunctionJdbcRepository extends JdbcRepository { public FunctionEntity findById(FunctionEntity 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<FunctionEntity> functions = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FunctionEntity.class)); if (functions.isEmpty()) { return null; } else { return functions.get(0); } } FunctionJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
FunctionJdbcRepository extends JdbcRepository { public FunctionEntity findById(FunctionEntity 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<FunctionEntity> functions = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FunctionEntity.class)); if (functions.isEmpty()) { return null; } else { return functions.get(0); } } FunctionJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); FunctionEntity create(FunctionEntity entity); FunctionEntity update(FunctionEntity entity); Pagination<Function> search(FunctionSearch domain); FunctionEntity findById(FunctionEntity entity); }
FunctionJdbcRepository extends JdbcRepository { public FunctionEntity findById(FunctionEntity 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<FunctionEntity> functions = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(FunctionEntity.class)); if (functions.isEmpty()) { return null; } else { return functions.get(0); } } FunctionJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); FunctionEntity create(FunctionEntity entity); FunctionEntity update(FunctionEntity entity); Pagination<Function> search(FunctionSearch domain); FunctionEntity findById(FunctionEntity entity);  }