I found some documents online, all of which show that flush is used to cache sessions and send SQL statements in the SQL Buffer to the database.
Previous batch operationsCodeAs follows:
// Specify the name of the Configuration. Find all configurations with the same name in the series. <br/> List <valveen> enlist = vadao. findbypzandserid (pzname, Sid); <br/> for (valveen: Enlist) {<br/> valveen. setzdy1 (zdy1); <br/> valveen. setzdy10 (zdy10); <br/> vadao. merge (valveen); <br/> vadao. getsession (). flush (); <br/> vadao. getsession (). clear (); </P> <p>}
In this way, errors that are inconsistent with the database are often flushed once every update. A little frequent, but I still don't know the exact reason. If it is placed outside of for, no error will occur. It seems that all others are used.If (count % 20) {// 20 and JDBC's batch size are consistent <br/> vadao. getsession (). flush (); <br/> vadao. getsession (). clear (); <br/>}This limits the number of data entries in the cache.