mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#1185 - Modify JDBC batch so it does not "auto flush" on non-Id non-generated property
This commit is contained in:
1 parent
c121618c0c
commit
37d001f754
8 files changed
+86
-13
No files matched your search
@@ -62,6 +62,11 @@ public final class BatchControl {
|
||||
|
||||
private int maxDepth;
|
||||
|
||||
/**
|
||||
* Size of the largest buffer.
|
||||
*/
|
||||
private int bufferMax;
|
||||
|
||||
/**
|
||||
* Create for a given transaction, PersistExecute, default size and getGeneratedKeys.
|
||||
*/
|
||||
@@ -174,8 +179,9 @@ public final class BatchControl {
|
||||
BatchedBeanHolder beanHolder = getBeanHolder(request);
|
||||
int bufferSize = beanHolder.append(request);
|
||||
|
||||
// return true if top level has hit batch size
|
||||
return bufferSize == batchSize && beanHolder.getOrder() == 100;
|
||||
bufferMax = Math.max(bufferMax, bufferSize);
|
||||
// flush if any buffer hits 10 times batch size
|
||||
return (bufferMax >= batchSize * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,14 +201,14 @@ public final class BatchControl {
|
||||
/**
|
||||
* Flush any batched PreparedStatements.
|
||||
*/
|
||||
protected void flushPstmtHolder() throws BatchedSqlException {
|
||||
private void flushPstmtHolder() throws BatchedSqlException {
|
||||
pstmtHolder.flush(getGeneratedKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute all the requests contained in the list.
|
||||
*/
|
||||
protected void executeNow(ArrayList<PersistRequest> list) throws BatchedSqlException {
|
||||
void executeNow(ArrayList<PersistRequest> list) throws BatchedSqlException {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i % batchSize == 0) {
|
||||
// hit the batch size so flush
|
||||
@@ -242,6 +248,7 @@ public final class BatchControl {
|
||||
private void flush(boolean resetTop) throws BatchedSqlException {
|
||||
|
||||
try {
|
||||
bufferMax = 0;
|
||||
if (!pstmtHolder.isEmpty()) {
|
||||
// Flush existing pstmts (updateSql or callableSql)
|
||||
flushPstmtHolder();
|
||||
|
||||
Reference in new issue
Block a user