How to return a stream id?

Asked

Viewed 36 times

0

I need to get the ID inside the findById, but I don’t understand how I can do it in stream.

 @Override
public void run(String... args) throws Exception {
    //TODO ler argumentos com data e workflow de processamento enviada pelo airflow
    try {
        List<String> arguments = Arrays.stream(args)
                .filter(key -> !key.contains("--spring.profiles.active"))
                .collect(Collectors.toList());

        //yyyy-MM-dd;
        TaskEnum task = TaskEnum.valueOf(arguments.get(0));
        LocalDate processingDate = LocalDate.parse(arguments.get(1));
        UUID airflowId = UUID.fromString(arguments.get(2));

        amqpHelper.createTopology(airflowId, task);
        Collection<OmniMessageDataDTO> entities = Arrays.asList();
        List<OmniMessageDataDTO> data = entities.stream().forEach(omniMessageDataRepository.findById());

        switch (task) {
            case PROCESSING_FETCH_RUPTURES_LIST -> fetchRupturesListService.processList(omniMessageDataDTO, airflowId);
        }
  • If it is the findById of spring-data-jpa, it returns an Optional with the entity, you can use the get method to retrieve the entity and then get the desired id. Example: findById(1). get(). getId() ... Take care to check if findById has returned anything.

  • @Andreyfrance people use pure JDBC in batches for performance purposes. I don’t know if they can do it that way for that reason. And there’s also the question that findbyid gets a parameter... I’m traveling cool on that.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.