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.
– Andrey França
@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.
– Binyamin Ely