skip to Main Content

There’s an error on using Spring batch JdbcBatchItemWriter.

insert into books(order_id, order_no, paid_payment_id) values (:orderId, :orderNo, :paidPaymentId)

enter image description here

  private JdbcBatchItemWriter<BooksEntity> booksWriter() {
    return new JdbcBatchItemWriterBuilder<BooksEntity>()
        .itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>())
        .dataSource(dataSource)
        .sql(
            "insert into books(order_id, order_no, paid_at, paid_payment_id, pay_method, pay_no, pg, service_type, status, transaction_amount, transaction_at, vat_amount, canceled_at, created_at) "
                + " values (:expectedCalculationAmount, :feeAmount, :orderId, :orderNo, :paidAt, :paidPaymentId, :payMethod, :payNo, pg, :serviceType, :status, :transactionAmount, :transactionAt, :vatAmount, :canceledAt, :createdAt)")
CalculationOriginalAccountBooksItemPreparedStatementSetter())
        .build();

  }
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/book?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
    password: root
    username: root
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    open-in-view: false
    hibernate:
      ddl-auto: update

S1009 Error I don’t know what that means.
Please help me.

2

Answers


  1. One thing I can notice right away is that you have used pg in the values instead of :pg which would get replaced during the query formation.

    Login or Signup to reply.
    • Try after adding ‘:’ before pg
    • Check CalculationOriginalAccountBooksItemPreparedStatementSetter with all columns are mapped according to the query.
    • Still it’s not working means try by add NamedJdbcTemplate in writer
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search