Hiberante batch update + Identity does not work

        for (ReviewQuestion question : questions) {
            List<ReviewQuestionOption> options = question.getOptions();
            if (options.isEmpty()) {
                continue;
            }
            Fraction basic = new Fraction(100).divide(options.size());
            for (int i = 0; i < options.size(); i++) {
                ReviewQuestionOption reviewQuestionOption = options.get(i);
                double weight = basic.multiply(i + 1).doubleValue();
                reviewQuestionOption.setPointWeight(BigDecimal.valueOf(Math.floor(weight * 10) / 10 + 1));
            }
            reviewQuestionOptionRepository.saveAll(options);
        }

spring.jpa.properties.hibernate.jdbc.batch_size=30
spring.jpa.properties.hibernate.batch_versioned_data=true
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?rewriteBatchedStatements=true
DB is MySQL
ReviewQuestionOption Id generate is @GeneratedValue(strategy = GenerationType.IDENTITY)

I want to find the reason why it’s not possible in the hibernate docs

That’s a limitation of the JPA APIs along with the way the database interaction works. When calling EntityManager#persist(Object), the JPA provider must execute an insert statement to retrieve the generated identifier via identity, because the method contract says the identifier will be set on the passed object after the method returns.

In Hibernate ORM 7 you will be able to use e.g. StatelessSession#insertMultiple(List<Object>) which in the future could make use of batching if the JDBC driver supports retrieving multiple generated identifiers, though I am not sure if the MySQL driver does support that.