2

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

for some reason I prefer using db auto increment primary key(GenerationType.IDENTITY) and not uuid . is any workaround ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.