I have a entity which looks like the below
@Entity public class MyEntity { .... @ElementCollection @MapKeyColumn(name = "key") @Column(name = "value") @CollectionTable("MyEntityMap") private Map<String, Integer> theMap; ... }
The map potentially has thousands of entries. I have set hibernate.jdbc.batch_size=50
I want to use the rewriteBatchedStatements=true parameter available in the MYSQL driver
jdbc.url=jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&rewriteBatchedStatements=true
So that the individual insert statements can be converted into INSERT INTO MyEntityMap () VALUES (), (), (), (), ()
After using these configurations if we switch on the general query log on MySQL we can observe that the insert statements are getting successfully converted however hibernate throws a BatchedTooManyRowsAffectedException
http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.hibernate/hibernate-core/4.1.9.Final/org/hibernate/jdbc/Expectations.java?av=f
line number 85 throws this exception.
Proposed solution –
There should be a way to hook in a custom Expectations implementation, i see there is a round about way for doing this using the SQLInsert annotation.
|