15 Aralık 2022 Perşembe

SpringBatch RepositoryItemReaderBuilder Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.batch.item.data.builder.RepositoryItemReaderBuilder;
repository metodu
Örnek
Elimizde şöyle bir kod olsun.
public interface DedWorkFlowResponseRepository extends
  JpaRepository<DedWorkFlowResponse, Long> {
  public Page<DedWorkFlowResponse> findByPickedIs(boolean picked,Pageable pageable);
}
Şöyle yaparız.
@Bean
@StepScope
public RepositoryItemReader<DedWorkFlowResponse> dedWorkFlowResponseItemReader() {

  return new RepositoryItemReaderBuilder<DedWorkFlowResponse>()
    .name("dedWorkFlowResponseItemReader")
    .methodName("findByPickedIs")
    .arguments(Collections.singletonList(false))
    .pageSize(100)
    .repository(dedWorkFlowResponseRepository)
    .sorts(Collections.singletonMap("id", Sort.Direction.ASC))
    .build();
}

Hiç yorum yok:

Yorum Gönder