vladmihalcea / high-performance-java-persistence

The High-Performance Java Persistence book and video course code examples
Apache License 2.0
1.31k stars 489 forks source link

Allow Batch insert when using Hibernate > 6.1 and MySQL #97

Closed fernando-silva closed 6 months ago

fernando-silva commented 6 months ago

Starting in Hibernate 6.2 the logic for ID generator changed which broke the current workaround for MySQL batch insert. See https://hibernate.atlassian.net/browse/HHH-16692

vladmihalcea commented 6 months ago

Batching works just fine. This is the output of the MySQLIdentityStatelessSessionTest.testPersist test case:

Connection:4, Time:6, Success:True, Type:Prepared, Batch:True, QuerySize:1, BatchSize:2, 
Query:["insert into post (created_by,created_on,title,updated_by,updated_on,version,id) values (?,?,?,?,?,?,default)"], 
Params:[(12, 93, High-Performance Java Persistence, Part 1, 12, 93, 0), (12, 93, High-Performance Java Persistence, Part 2, 12, 93, 0)]
fernando-silva commented 6 months ago

I just executed using master branch (Hibernate 6.4.4.Final) and test failed with expected assert error

Screenshot 2024-05-20 at 13 01 00
vladmihalcea commented 6 months ago

That may be because you are not using this commit

https://github.com/vladmihalcea/high-performance-java-persistence/commit/6c9da793122ce7fb5d8d3a2dcc0d717212af88b5

fernando-silva commented 6 months ago

Indeed it's using

Screenshot 2024-05-20 at 13 11 57 Screenshot 2024-05-20 at 13 11 46 Screenshot 2024-05-20 at 13 13 16