aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbartolomiew <bart_olomiew@yahoo.fr>2012-10-28 08:41:27 +0100
committerJames Moger <james.moger@gmail.com>2012-11-02 14:33:26 -0400
commit68930d845c27578c60fbf6d083a5a9e36fd5078e (patch)
treeee47ab1943f7c1ef0d8317709d023f2ebc0a7bf1 /src
parent1f06dc3216fdb327a60bb3e46a35c948c69d4b97 (diff)
downloadiciql-68930d845c27578c60fbf6d083a5a9e36fd5078e.tar.gz
iciql-68930d845c27578c60fbf6d083a5a9e36fd5078e.zip
Allows to gain full control of transactions
Diffstat (limited to 'src')
-rw-r--r--src/com/iciql/Db.java38
-rw-r--r--src/com/iciql/TableDefinition.java6
2 files changed, 43 insertions, 1 deletions
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java
index caec637..32b7c6a 100644
--- a/src/com/iciql/Db.java
+++ b/src/com/iciql/Db.java
@@ -1,6 +1,7 @@
/*
* Copyright 2004-2011 H2 Group.
* Copyright 2011 James Moger.
+ * Copyright 2012 Frederic Gaillard.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,6 +69,9 @@ public class Db {
private DbUpgrader dbUpgrader = new DefaultDbUpgrader();
private final Set<Class<?>> upgradeChecked = Collections.synchronizedSet(new HashSet<Class<?>>());
+ private boolean skipCreate;
+ private boolean autoSavePoint = true;
+
static {
TOKENS = Collections.synchronizedMap(new WeakIdentityHashMap<Object, Token>());
DIALECTS = Collections.synchronizedMap(new HashMap<String, Class<? extends SQLDialect>>());
@@ -563,6 +567,11 @@ public class Db {
}
Savepoint prepareSavepoint() {
+ // don't change auto-commit mode.
+ // don't create save point.
+ if (!autoSavePoint) {
+ return null;
+ }
// create a savepoint
Savepoint savepoint = null;
try {
@@ -731,4 +740,33 @@ public class Db {
JdbcUtils.closeSilently(stat);
}
}
+
+ /**
+ * Allow to enable/disable globally createIfRequired in TableDefinition.
+ * For advanced user wanting to gain full control of transactions.
+ * Default value is false.
+ * @param skipCreate
+ */
+ public void setSkipCreate(boolean skipCreate) {
+ this.skipCreate = skipCreate;
+ }
+
+ public boolean getSkipCreate() {
+ return this.skipCreate;
+ }
+
+ /**
+ * Allow to enable/disable usage of save point.
+ * For advanced user wanting to gain full control of transactions.
+ * Default value is false.
+ * @param autoSavePoint
+ */
+ public void setAutoSavePoint(boolean autoSavePoint) {
+ this.autoSavePoint = autoSavePoint;
+ }
+
+ public boolean getAutoSavePoint() {
+ return this.autoSavePoint;
+ }
+
}
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java
index 1ecf394..e96b61c 100644
--- a/src/com/iciql/TableDefinition.java
+++ b/src/com/iciql/TableDefinition.java
@@ -1,7 +1,7 @@
/*
* Copyright 2004-2011 H2 Group.
* Copyright 2011 James Moger.
- * Copyright 2012 Frédéric Gaillard.
+ * Copyright 2012 Frederic Gaillard.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -839,6 +839,10 @@ public class TableDefinition<T> {
}
TableDefinition<T> createIfRequired(Db db) {
+ // globally enable/disable check of create if required
+ if (db.getSkipCreate()) {
+ return this;
+ }
if (!createIfRequired) {
// skip table and index creation
// but still check for upgrades