【发布时间】:2020-07-17 05:23:25
【问题描述】:
我正在尝试通过 Mysql 使用 SpringBoot Data Jpa 实现批量插入/更新记录, 这是我的 yml 配置:
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_size=500
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
spring.jpa.properties.hibernate.generate_statistics=true
我在这里使用 mysql 自增列作为主键
public class Customer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
我在 Google 上搜索到批处理操作不适用于 GenerationType.IDENTITY, 但我也注意到 mysql 不支持 GenerationType.SEQUENCE 那么我怎么能用jpa的saveAll(data)方法和mysql DB完成浴插入/更新
谢谢
【问题讨论】:
标签: mysql spring-boot spring-data-jpa