Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
Spring batch with spring data

Is there a way to integrate spring batch with spring data? I see RepositoryItemReader and RepositoryItemWriter in spring documentation.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You are totally right. Spring batch can be easily be integrated with spring data. Here example of item reader:

    @Bean(name = "lotteryInfoReader")
    @StepScope
    public RepositoryItemReader<LotteryInfo> reader() {
        RepositoryItemReader<LotteryInfo> reader = new RepositoryItemReader<>();
        reader.setRepository(lotteryInfoRepository);
        reader.setMethodName("findAll");
        reader.setSort(Collections.singletonMap("name", Sort.Direction.ASC));
        return reader;
    }

Here is another example with using hibernate without spring data :

    @Bean(name = "drawsWriter")
    @StepScope
    public ItemWriter<? super List<Draw>> writer() {
        return items -> items.stream()
                .flatMap(Collection::stream)
                .forEach(entityManager::merge);
    }
about 4 years ago · Santiago Trujillo Denunciar

0

well i'm doing that in a different way i'm injecting the service into the job configuration and invoke the method that's available on the JpaRepository, like this example

    @Bean
    @StepScope
    public ItemWriter<Customer> customerItemWriter2() {
        return items -> {
            for (Customer item : items) {

                customerService.save(item);
            }
        };
    }
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda