I would like to change org.hibernate.jdbc.BatchingBatcher and org.hibernate.jdbc.NonBatchingBatcher to fail silently if the number of rows inserted doesn't match the number it expected. I want to do this because I have a before-insert trigger that denies insertion on duplicate or banned rows, so if a row shouldn't be inserted "NULL" is returned to JDBC, signifying that no insert should be performed.
I propose changing line 92 of Batching Batcher:
Code:
if ( rowCount<expectedRowCount ) {
throw new StaleStateException(
"Batch update returned unexpected row count from update: " + i +
" actual row count: " + rowCount +
" expected: " + expectedRowCount
);
}
by just commenting out the stalestateexception throwage. This would fix my problem, but will this leave hibernate in a safe state moving forward?
Is this exception relied on heavily somewhere else?
Regards,
B