diff options
| author | Brian S. O'Neill <bronee@gmail.com> | 2006-10-02 06:08:44 +0000 | 
|---|---|---|
| committer | Brian S. O'Neill <bronee@gmail.com> | 2006-10-02 06:08:44 +0000 | 
| commit | fb3696bc72ce7bcbf17a5188b7fec1c5b690ad23 (patch) | |
| tree | f71aec688dd3be3188ee179c7bfdac5668c3758e | |
| parent | 83dc6080af2a6e00e6aa383af5fe6d3382eea43c (diff) | |
Add support SNAPSHOT isolation level.
| -rw-r--r-- | docs/CarbonadoGuide.odt | bin | 56032 -> 56398 bytes | |||
| -rw-r--r-- | docs/CarbonadoGuide.pdf | bin | 417058 -> 432918 bytes | |||
| -rw-r--r-- | src/main/java/com/amazon/carbonado/IsolationLevel.java | 13 | ||||
| -rw-r--r-- | src/main/java/com/amazon/carbonado/OptimisticLockException.java | 2 | ||||
| -rw-r--r-- | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java | 6 | 
5 files changed, 21 insertions, 0 deletions
diff --git a/docs/CarbonadoGuide.odt b/docs/CarbonadoGuide.odt Binary files differindex d6b977b..3530801 100644 --- a/docs/CarbonadoGuide.odt +++ b/docs/CarbonadoGuide.odt diff --git a/docs/CarbonadoGuide.pdf b/docs/CarbonadoGuide.pdf Binary files differindex 20f763f..56414db 100644 --- a/docs/CarbonadoGuide.pdf +++ b/docs/CarbonadoGuide.pdf diff --git a/src/main/java/com/amazon/carbonado/IsolationLevel.java b/src/main/java/com/amazon/carbonado/IsolationLevel.java index 5f963b2..7571205 100644 --- a/src/main/java/com/amazon/carbonado/IsolationLevel.java +++ b/src/main/java/com/amazon/carbonado/IsolationLevel.java @@ -26,6 +26,7 @@ package com.amazon.carbonado;   * <li>{@link #READ_UNCOMMITTED}
   * <li>{@link #READ_COMMITTED}
   * <li>{@link #REPEATABLE_READ}
 + * <li>{@link #SNAPSHOT}
   * <li>{@link #SERIALIZABLE}
   * </ul>
   *
 @@ -35,6 +36,11 @@ package com.amazon.carbonado;   * iteration. It releases locks during iteration rather than holding on to them
   * until the transaction exits.
   *
 + * <p>{@code SNAPSHOT} isolation is special in that it uses multiversion
 + * concurrency control (MVCC). A commit may fail with an {@link
 + * OptimisticLockException}. Few repositories are expected to support this
 + * level, however.
 + *
   * @author Brian S O'Neill
   * @see Repository#enterTransaction(IsolationLevel)
   * @see Transaction
 @@ -73,6 +79,13 @@ public enum IsolationLevel {      /**
       * Indicates that dirty reads, non-repeatable reads and phantom reads are
 +     * prevented. Commits can still fail however, as snapshot isolation avoids
 +     * using locks.
 +     */
 +    SNAPSHOT,
 +
 +    /**
 +     * Indicates that dirty reads, non-repeatable reads and phantom reads are
       * prevented. Phantoms are records returned as a result of a search, but
       * which were not seen by the same transaction when the identical search
       * criteria was previously used. For example, another transaction may have
 diff --git a/src/main/java/com/amazon/carbonado/OptimisticLockException.java b/src/main/java/com/amazon/carbonado/OptimisticLockException.java index 2a782d1..b4a43de 100644 --- a/src/main/java/com/amazon/carbonado/OptimisticLockException.java +++ b/src/main/java/com/amazon/carbonado/OptimisticLockException.java @@ -21,6 +21,8 @@ package com.amazon.carbonado;  /**
   * An OptimisticLockException is thrown if the {@link Repository} is using
   * optimistic locking for concurrency control, and lock aquisition failed.
 + * This exception may also be thrown if multiversion concurrency control (MVCC)
 + * is being used and the commit fails.
   *
   * @author Brian S O'Neill
   */
 diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java index 6e53354..97be915 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java @@ -92,6 +92,9 @@ public class JDBCRepository              return Connection.TRANSACTION_READ_COMMITTED;
          case REPEATABLE_READ:
              return Connection.TRANSACTION_REPEATABLE_READ;
 +        case SNAPSHOT:
 +            // TODO: not accurate for all databases.
 +            return Connection.TRANSACTION_SERIALIZABLE;
          case SERIALIZABLE:
              return Connection.TRANSACTION_SERIALIZABLE;
          }
 @@ -117,6 +120,9 @@ public class JDBCRepository              case REPEATABLE_READ:
                  desiredLevel = IsolationLevel.SERIALIZABLE;
                  break;
 +            case SNAPSHOT:
 +                desiredLevel = IsolationLevel.SERIALIZABLE;
 +                break;
              case SERIALIZABLE: default:
                  return null;
              }
  | 
