After updating hibernate version from 5.6.12 to 6.1.6, a problem appeared. If Entity has field with annotation @Generated() and hibernate’s properties have parameter jdbc.batch_size > 0 then when new object of entity is saved to the database, an error appears in the logs and the saving does not occur. The error occurs in the class org.hibernate.metamodel.mapping.internal.GeneratedValuesProcessor. And the problem is that when in entity there is an annotation @Generated over the field, then in hibernate, first, it is saved in the database, and then these generated fields are received from the database. And apparently, when there is jdbc.batch_size > 0 setting, then INSERT to the database does not occur immediately, and SELECT tries to find a line in the database that is not there yet. With the old version of hibernate 5.6.12 everything worked without errors. Link to https://discourse.hibernate.org/t/problem-with-generated-and-jdbc-batch-size/7245 with more info. And i have attached test cases. |