Skip to content

jojoldu/spring-batch-querydsl

Repository files navigation

Spring Batch QuerydslItemReader

Querydsl ItemReader For Spring Batch

Usage

Requires

  • Java 8
  • Spring Batch

Dependency

compile('com.github.jojoldu.spring-batch-querydsl:spring-batch-querydsl-reader:2.4.8')

QuerydslPagingItemReader

Common paging reader

@Bean
public QuerydslPagingItemReader<Product> reader() {
    return new QuerydslPagingItemReader<>(emf, chunkSize, queryFactory -> queryFactory
            .selectFrom(product)
            .where(product.createDate.eq(jobParameter.getTxDate())));
}

QuerydslNoOffsetPagingItemReader

No offset query is required due to the performance problem of the paging query.

@Bean
public QuerydslNoOffsetPagingItemReader<Product> reader() {
    // 1. No Offset Option
    QuerydslNoOffsetNumberOptions<Product, Long> options =
            new QuerydslNoOffsetNumberOptions<>(product.id, Expression.ASC);

    // 2. Querydsl Reader
    return new QuerydslNoOffsetPagingItemReader<>(emf, chunkSize, options, queryFactory -> queryFactory
            .selectFrom(product)
            .where(product.createDate.eq(jobParameter.getTxDate())));
}

Logging

logging:
  level:
    org:
      springframework:
        batch: 
            item.querydsl.reader: DEBUG

About

스프링배치와 QuerydslPagingItemReader

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages