edu.internet2.middleware.grouper.hibernate
Enum GrouperTransactionType

java.lang.Object
  extended by java.lang.Enum<GrouperTransactionType>
      extended by edu.internet2.middleware.grouper.hibernate.GrouperTransactionType
All Implemented Interfaces:
Serializable, Comparable<GrouperTransactionType>

public enum GrouperTransactionType
extends Enum<GrouperTransactionType>

enum of possible transaction types

Author:
mchyzer

Enum Constant Summary
NONE
          even if in a current tx, do not use transactions
READ_WRITE_NEW
          even if in the middle of a transaction, create a new read/write autonomous nested transaction.
READ_WRITE_OR_USE_EXISTING
          use the current transaction if one exists.
READONLY_NEW
          even if in the middle of a transaction, create a new readonly autonomous nested transaction.
READONLY_OR_USE_EXISTING
          use the current transaction if one exists, if not, create a new readonly tx.
 
Method Summary
abstract  void checkCompatibility(GrouperTransactionType existingGrouperTransactionType)
          return if readonly.
abstract  GrouperTransactionType grouperTransactionTypeToUse()
          convert the declared tx type to one that is not "if exists"...
abstract  boolean isNewAutonomous()
          return if new autonomous transaction
abstract  boolean isReadonly()
          return if readonly.
abstract  boolean isTransactional()
          if there is a transaction (e.g.
static GrouperTransactionType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static GrouperTransactionType valueOfIgnoreCase(String string)
          do a case-insensitive matching
static GrouperTransactionType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

READONLY_OR_USE_EXISTING

public static final GrouperTransactionType READONLY_OR_USE_EXISTING
use the current transaction if one exists, if not, create a new readonly tx. Note, the enclosing transaction could be readonly or readwrite, and no error will be thrown. However, no matter what, this code cannot commit or rollback...


NONE

public static final GrouperTransactionType NONE
even if in a current tx, do not use transactions


READONLY_NEW

public static final GrouperTransactionType READONLY_NEW
even if in the middle of a transaction, create a new readonly autonomous nested transaction. Code in this state cannot commit or rollback.


READ_WRITE_OR_USE_EXISTING

public static final GrouperTransactionType READ_WRITE_OR_USE_EXISTING
use the current transaction if one exists. If there is a current transaction, it MUST be read/write or there will be an exception. If there isnt a transaction in scope, then create a new read/write one. If you do not commit at the end, and there is a normal return (no exception), then the transaction will be committed if new, and not if reusing an existing one. If there is an exception, and the tx is new, it will be rolledback. If there is an exception and the tx is reused, the tx will not be touched, and the exception will propagate.


READ_WRITE_NEW

public static final GrouperTransactionType READ_WRITE_NEW
even if in the middle of a transaction, create a new read/write autonomous nested transaction. If this block is exited normally it will always commit. If exception is thrown, it will always rollback.

Method Detail

values

public static GrouperTransactionType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (GrouperTransactionType c : GrouperTransactionType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static GrouperTransactionType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

valueOfIgnoreCase

public static GrouperTransactionType valueOfIgnoreCase(String string)
do a case-insensitive matching

Parameters:
string -
Returns:
the enum or null or exception if not found

isReadonly

public abstract boolean isReadonly()
return if readonly. note if readonly_if_not_exist it will throw exception since it doesnt know if readonly or not...

Returns:
true if known readonly, false, if known read_write

isNewAutonomous

public abstract boolean isNewAutonomous()
return if new autonomous transaction

Returns:
true if new, false if not

isTransactional

public abstract boolean isTransactional()
if there is a transaction (e.g. not NONE)

Returns:
the transaction type

checkCompatibility

public abstract void checkCompatibility(GrouperTransactionType existingGrouperTransactionType)
                                 throws GrouperDAOException
return if readonly. note if readonly_if_not_exist it will throw exception since it doesnt know if readonly or not...

Parameters:
existingGrouperTransactionType - if null, no parent, if not, then this is the enclosing type
Throws:
GrouperDAOException - if there is a compatibility problem

grouperTransactionTypeToUse

public abstract GrouperTransactionType grouperTransactionTypeToUse()
convert the declared tx type to one that is not "if exists"...

Returns:
the type to use (e.g. not an if exists one)