[java-plugin-storage-jdbc] 01/03: OSJ-342 Investigate Strategies to end of life our use of Hibernate in V5 https://shibboleth.atlassian.net/browse/OSJ-342
Rod Widdowson
rdw at steadingsoftware.com
Tue May 24 16:02:28 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-plugin-storage-jdbc.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-storage-jdbc.git;a=commit;h=88491e0a3b07e5c4517d22b6489741a09f758a44
commit 88491e0a3b07e5c4517d22b6489741a09f758a44
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon May 23 14:41:36 2022 +0100
OSJ-342 Investigate Strategies to end of life our use of Hibernate in V5
https://shibboleth.atlassian.net/browse/OSJ-342
Allow setting of TransactionIsolation.
---
.../plugin/storage/jdbc/impl/JDBCStorageService.java | 19 ++++++++++++++++---
.../storage/jdbc/impl/JDBCStorageServiceTest.java | 2 +-
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
index aeefb1d..da00224 100644
--- a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
+++ b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
@@ -111,12 +111,14 @@ public final class JDBCStorageService extends AbstractStorageService implements
/** The SQL to delete a given context. */
static final String DEFAULT_DELETE_BY_CONTEXT_SQL = "DELETE FROM StorageRecords WHERE context = ? ";
-
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(JDBCStorageService.class);
/** How many times do we try an operation before giving up? */
private int transactionRetry = 3;
+
+ /** What transaction isolation do we want? */
+ private int transactionIsolation = Connection.TRANSACTION_SERIALIZABLE;
/** Error messages that signal a transaction should be retried. */
@Nonnull @NonnullElements private Collection<String> retryableErrors = Collections.emptyList();
@@ -224,7 +226,18 @@ public final class JDBCStorageService extends AbstractStorageService implements
throw new ConstraintViolationException("transaction retry must be positive");
}
}
-
+
+ /** Set the parameter that will be passed to {@link Connection#setTransactionIsolation(int)}.
+ * @param what the value to set
+ */
+ public void setTransactionIsolation(int what) {
+ Constraint.isTrue(what == Connection.TRANSACTION_NONE ||
+ what == Connection.TRANSACTION_READ_COMMITTED || what == Connection.TRANSACTION_READ_UNCOMMITTED ||
+ what == Connection.TRANSACTION_REPEATABLE_READ || what == Connection.TRANSACTION_SERIALIZABLE,
+ "Invalid value for TransactionIsolation");
+ transactionIsolation = what;
+ }
+
/** Set the {@link DataSource}.
* @param source what to set.
*/
@@ -982,7 +995,7 @@ public final class JDBCStorageService extends AbstractStorageService implements
@Nonnull private Connection getConnection(final boolean autoCommit) throws SQLException {
final Connection conn = dataSource.getConnection();
conn.setAutoCommit(autoCommit);
- conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ conn.setTransactionIsolation(transactionIsolation);
return conn;
}
diff --git a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java b/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
index 8f15084..92e148f 100644
--- a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
+++ b/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
@@ -246,7 +246,7 @@ public class JDBCStorageServiceTest extends StorageServiceTest {
@Test
public void caseSensitiveContext() throws IOException {
- assertTrue(shared.create("foo", "bar", "value", null));
+ assertTrue(shared.create("foo", "bar", "value", null));
assertTrue(shared.create("FOO", "bar", "value", null));
StorageRecord<?> rec1 = shared.read("foo", "bar");
StorageRecord<?> rec2 = shared.read("FOO", "bar");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list