@Test @Sql(scripts = { "/sql/clearRecovery.sql", "/sql/insertRecoveryData.sql" }) public void test_find_by_invalid_id_should_return_null() { RecoveryEntity recoveryEntity = RecoveryEntity.builder().id("5").build(); recoveryEntity.setTenantId("default"); RecoveryEntity result = recoveryJdbcRepository.findById(recoveryEntity); assertNull(result); }
public RecoveryEntity findById(RecoveryEntity 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<RecoveryEntity> recovery = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(RecoveryEntity.class)); if (recovery.isEmpty()) { return null; } else { return recovery.get(0); } }
RecoveryJdbcRepository extends JdbcRepository { public RecoveryEntity findById(RecoveryEntity 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<RecoveryEntity> recovery = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(RecoveryEntity.class)); if (recovery.isEmpty()) { return null; } else { return recovery.get(0); } } }
RecoveryJdbcRepository extends JdbcRepository { public RecoveryEntity findById(RecoveryEntity 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<RecoveryEntity> recovery = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(RecoveryEntity.class)); if (recovery.isEmpty()) { return null; } else { return recovery.get(0); } } RecoveryJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
RecoveryJdbcRepository extends JdbcRepository { public RecoveryEntity findById(RecoveryEntity 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<RecoveryEntity> recovery = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(RecoveryEntity.class)); if (recovery.isEmpty()) { return null; } else { return recovery.get(0); } } RecoveryJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); RecoveryEntity create(RecoveryEntity entity); RecoveryEntity update(RecoveryEntity entity); Pagination<Recovery> search(RecoverySearch domain); RecoveryEntity findById(RecoveryEntity entity); }
RecoveryJdbcRepository extends JdbcRepository { public RecoveryEntity findById(RecoveryEntity 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<RecoveryEntity> recovery = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(RecoveryEntity.class)); if (recovery.isEmpty()) { return null; } else { return recovery.get(0); } } RecoveryJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); RecoveryEntity create(RecoveryEntity entity); RecoveryEntity update(RecoveryEntity entity); Pagination<Recovery> search(RecoverySearch domain); RecoveryEntity findById(RecoveryEntity entity);  }