[2019-08-2919:54:27.819] [ERROR] [org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:137)] [qtp1165897474-48619] : HHH000315: Exception executing batch [Batch update returned unexpected row count from update [1]; actual row count: 2; expected: 1] [2019-08-2919:54:27.824] [ERROR] [com.sf.hos.itv.biz.impl.CandidatePushBiz.SendEmails(CandidatePushBiz.java:569)] [qtp1165897474-48619] : com.sf.hos.itv.biz.impl.CandidatePushBiz.SendEmails error org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [1]; actual row count: 2; expected: 1 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:89) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:73) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.checkRowCounts(BatchingBatch.java:151) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:128) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:111) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:163) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.executeBatch(JdbcCoordinatorImpl.java:226) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:482) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:67) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1191) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1675) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380) ~[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at com.sf.novatar.base.dao.CommonDao.findFirstByAny(CommonDao.java:812) ~[sf-novatar-frame-1.14.20171110.jar:1.14] at com.sf.novatar.base.dao.BaseBeanDao.findFirstBy(BaseBeanDao.java:181) ~[sf-novatar-frame-1.14.20171110.jar:1.14] at com.sf.hos.core.dao.impl.HosSapPersonDao.getSapPersonByEmpNum(HosSapPersonDao.java:60) ~[sf-hos-core-1.0.20190719.jar:1.0] .............
/** * detect in-memory changes, determine if the changes are to tables * named in the query and, if so, complete execution the flush */ protectedbooleanautoFlushIfRequired(Set querySpaces)throws HibernateException { errorIfClosed(); if ( ! isTransactionInProgress() ) { // do not auto-flush while outside a transaction returnfalse; } AutoFlushEvent event = new AutoFlushEvent( querySpaces, this ); for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) { listener.onAutoFlush( event ); } return event.isFlushRequired(); } //大致意思和流程为:获取当前查询涉及到的querySpaces也就是tables,然后去和session缓存内的需要updte的querySpaces进行比较。如果存在则刷新flush至数据库。