[求助]Mysql在Hibernate中,如何使用批量提交?
Mysql在Hibernate中,如何使用批量提交?PS:
以下的配置在MYSQL中无效。。。
hibernate.jdbc.batch_size 20
Test.java
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
for ( int i=0; i<100000; i++ ) {
Customer customer = new Customer(.....);
session.save(customer);
if ( i % 20 == 0 ) { //20, same as the JDBC batch size
//flush a batch of inserts and release memory:
session.flush();
session.clear();
}
}
tx.commit();
session.close();
-----------------------------
谢谢!