Author: tolusha
Date: 2011-03-25 04:50:43 -0400 (Fri, 25 Mar 2011)
New Revision: 4173
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestor.java
Log:
EXOJCR-1272: the big batch commit in RDMBS restore failed on Oracle
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestor.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestor.java 2011-03-25
07:41:56 UTC (rev 4172)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestor.java 2011-03-25
08:50:43 UTC (rev 4173)
@@ -66,6 +66,11 @@
public class DBRestor implements DataRestor
{
/**
+ * The maximum possible batch size.
+ */
+ private final int MAXIMUM_BATCH_SIZE = 1000;
+
+ /**
* List of temporary files.
*/
private final List<File> spoolFileList = new ArrayList<File>();
@@ -366,6 +371,10 @@
parameters += "?" + (i == targetColumnCount - 1 ? "" :
",");
}
+ int batchSize = 0;
+ insertNode =
+ jdbcConn.prepareStatement("INSERT INTO " + tableName + "
(" + names + ") VALUES(" + parameters + ")");
+
// set data
outer : while (true)
{
@@ -406,13 +415,6 @@
stream = len == -1 ? null : spoolInputStream(contentReader, len);
}
- if (insertNode == null)
- {
- insertNode =
- jdbcConn.prepareStatement("INSERT INTO " + tableName +
" (" + names + ") VALUES(" + parameters
- + ")");
- }
-
if (restoreRule.getSkipColumnIndex() != null &&
restoreRule.getSkipColumnIndex() == i)
{
targetIndex--;
@@ -529,13 +531,18 @@
insertNode.setNull(targetIndex + 1, columnType.get(i));
}
}
- if (insertNode != null)
+
+ // add statement to batch
+ insertNode.addBatch();
+
+ if (++batchSize == MAXIMUM_BATCH_SIZE)
{
- insertNode.addBatch();
+ insertNode.executeBatch();
+ batchSize = 0;
}
}
- if (insertNode != null)
+ if (batchSize != 0)
{
insertNode.executeBatch();
}