JdbcBatchItemWriter错误,参数索引超出范围。

huangapple go评论66阅读模式
英文:

JdbcBatchItemWriter Error Parameter index out of range

问题

There's an error on using Spring batch JdbcBatchItemWriter.

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

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

英文:

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.

答案1

得分: 1

你现在是我的中文翻译,代码部分不要翻译,只返回翻译好的部分,不要有别的内容,不要回答我要翻译的问题。以下是要翻译的内容:

我立刻注意到的一件事是,您在值中使用了 pg 而不是 :pg,后者会在查询形成时被替换。

英文:

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.

答案2

得分: 0

  • 在添加 ':' 之前尝试 pg
  • 检查 CalculationOriginalAccountBooksItemPreparedStatementSetter,确保所有列都根据查询进行了映射。
  • 仍然不起作用的话,尝试在 writer 中添加 NamedJdbcTemplate。
英文:
  • 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

huangapple
  • 本文由 发表于 2023年5月18日 10:41:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277389.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定