Я использую Spring Boot 3.5.5 и Spring Data JPA.@Entity
@Table(name = "orders")
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long orderId;
private String firstName;
private String lastName;
private String email;
private BigDecimal cost;
private String itemId;
private String itemName;
private Date shipDate;
}
< /code>
mainapp.java
@SpringBootApplication
public class LinkedinBatchApplication {
public static String ORDER_SQL = "select order_id, first_name, last_name, "
+ "email, cost, item_id, item_name, ship_date "
+ "from orders order by order_id";
@Bean
public ItemReader itemReader(DataSource dataSource) {
return new JdbcCursorItemReaderBuilder()
.dataSource(dataSource)
.name("jdbcCursorItemReader")
.sql(ORDER_SQL)
.rowMapper(new OrderRowMapper()) // Use your custom RowMapper
.build();
}
@Bean
public Step chunkBasedStep(JobRepository jobRepository,
PlatformTransactionManager transactionManager,
ItemReader itemReader) {
return new StepBuilder("chunkBasedStep", jobRepository)
.chunk(3, transactionManager)
.reader(itemReader)
.writer(new ItemWriter() {
@Override
public void write(Chunk
Подробнее здесь: https://stackoverflow.com/questions/797 ... as-updated