Reputation: 1471
I'm trying to implement batch insert/update records with SpringBoot Data Jpa with Mysql, here is my yml config:
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
And I use an mysql auto increment column as primary key, here
public class Customer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
I've googled that batch ops will not work with GenerationType.IDENTITY, but also I notice that mysql not support GenerationType.SEQUENCE then how could I accomplish bath insert/update with jpa's saveAll(data) method with mysql DB
Thank you
Upvotes: 2
Views: 480
Reputation: 81862
I've googled that batch ops will not work with GenerationType.IDENTITY, but also I notice that mysql not support GenerationType.SEQUENCE
Set the id in the application. For example using a UUID
Upvotes: 1