在HIbernate commit() 和 flush()遇到了这个例子
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();
session.save(customer)
我的理解是当我们这样做时,休眠将数据库会话与休眠同步session.update(....)
?它是否仅在提交/刷新/刷新时而不是在更新/保存时进行晒黑?