| java.lang.Object com.completex.objective.components.persistency.key.impl.AbstractKeyGenerator com.completex.objective.components.persistency.key.impl.AbstractOdalSequenceKeyGenerator
All known Subclasses: com.completex.objective.components.persistency.key.impl.OdalSimpleSequenceKeyGenerator,
AbstractOdalSequenceKeyGenerator | abstract public class AbstractOdalSequenceKeyGenerator extends AbstractKeyGenerator implements ComplexSequenceKeyGenerator(Code) | | Sequence Key Generator based on emulated sequence. It is table based with default table name
odal_sequence.
Example (staticAttributes section describes possible attributes to set):
// keyGenerator = {
// class = com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl
// staticAttributes = {
// name = CONTACT_SEQ # Sequence name - either in the "table" (see the next attribute) or name of a
// # database sequence when it is appropriate with accordance with the
// # policy used (see "policy" attribute below).
// table = # Optional attribute specifying the table used for storing ODAL sequences.
// # If not set the default - "odal_sequence" - is used
// sameTransaction = # Optional attribute specifying if the sequence has to be generated in the same
// # (current) transaction. If false - a separate transaction is open to generate
// # a sequence from the "table" when it is appropriate with accordance with the
// # policy used (see "policy" attribute below).
// # Default is false.
// policy = # Optional attribute - policy class name
// # (com.completex.objective.components.persistency.key.OdalKeyPolicy instance - assumed to have no arguments constructor) -
// # if not set - com.completex.objective.components.persistency.key.impl.OdalKeyPolicyImpl
// # is used
// }
// }
This class will generate the next sequence number according to the policy
(com.completex.objective.components.persistency.key.OdalKeyPolicy) used.
There are 3 possible way to generate sequence using this class -
1. Odal key table.
2. Database sequence
3. Database identity (or auto-increment) field.
Odal Key Policy determines priorities give to each of the above mentioned methods.
If all sequence generation method priorities are either disabled or not supported -
exception is thrown.
Otherwise: the highest priority is calculated and the sequence generation method associated with it is used.
NOTE: if the database does not support record level locks - Odal key table based sequence generation method
is given the lowest priority though it is NOT considered disabled, meaning even not multi-process safe it
is still may be used as the last resort.
With default Odal Key Policy, the priorities in descending order are ODAL KEY PRIORITY,
SEQUENCE PRIORITY, IDENTITY PRIORITY. If the database does not support
record level locks ODAL KEY PRIORITY moves to the 3rd (the lowest) position.
author: Gennady Krizhevsky |
Inner Class :static interface ExecPriority extends Comparable | |
Inner Class :abstract protected class AbstractExecPriority implements ExecPriority | |
Inner Class :protected class OdalKeyExecPriority extends AbstractExecPriority | |
Inner Class :protected class SeqExecPriority extends AbstractExecPriority | |
Inner Class :protected class IdentityExecPriority extends AbstractExecPriority | |
Method Summary | |
protected ExecPriority[] | extractPriorities(DatabasePolicy databasePolicy) | protected Object | generateSequenceFromOdalTable(Transaction transaction, Persistency persistency, String objectName) | protected Object | generateSequenceFromSupportingKeyGenerator(Transaction transaction, Persistency persistency, String objectName) | protected ExecPriority | getIdentityPriority(DatabasePolicy databasePolicy) | public Object | getNextKeyPlain(Transaction transaction, Persistency persistency, String objectName) | public OdalKeyPolicy | getOdalKeyPolicy() | protected ExecPriority | getOdalKeyPriority(DatabasePolicy databasePolicy) | protected ExecPriority | getSequencePriority(DatabasePolicy databasePolicy) | public String | getTableName() | public void | insertValue(Transaction transaction, Persistency persistency, PersistentEntry persistentEntry) | protected boolean | isInsertConditionSatisfied0(PersistentEntry persistentEntry) | public boolean | isSameTransaction() | protected void | postExecPriority(Object id, ExecPriority priotity) | public void | setOdalKeyPolicy(OdalKeyPolicy odalKeyPolicy) | public void | setSameTransaction(boolean sameTransaction) | public void | setStaticParameters(Object staticParameters) | public void | setTableName(String tableName) | protected void | sortPriorities(ExecPriority[] priotities) | public void | updateValue(Transaction transaction, Persistency persistency, PersistentEntry persistentEntry, boolean complexDirty) | protected void | validatePrioritiesEnabled(ExecPriority[] priotities) |
DEFAULT_SEQ_TABLE | final public static String DEFAULT_SEQ_TABLE(Code) | | |
DISABLED_FOR_IDENTITY_KEY | final public static String DISABLED_FOR_IDENTITY_KEY(Code) | | |
sameTransaction | protected boolean sameTransaction(Code) | | |
supportingKeyGenerator | protected AbstractKeyGenerator supportingKeyGenerator(Code) | | For databases that do not have explicit record level locks (like HSQLDB)
but support sequences the supporting key generator can be used
instead of the table one.
|
AbstractOdalSequenceKeyGenerator | protected AbstractOdalSequenceKeyGenerator(String tableName, boolean sameTransaction)(Code) | | |
AbstractOdalSequenceKeyGenerator | protected AbstractOdalSequenceKeyGenerator()(Code) | | |
isInsertConditionSatisfied0 | protected boolean isInsertConditionSatisfied0(PersistentEntry persistentEntry)(Code) | | |
isSameTransaction | public boolean isSameTransaction()(Code) | | true if the sequence is taken in current transaction |
postExecPriority | protected void postExecPriority(Object id, ExecPriority priotity)(Code) | | |
setSameTransaction | public void setSameTransaction(boolean sameTransaction)(Code) | | Set flag that indicates if the sequence is to be taken in current transaction
Parameters: sameTransaction - static attributes |
setStaticParameters | public void setStaticParameters(Object staticParameters)(Code) | | |
setTableName | public void setTableName(String tableName)(Code) | | Parameters: tableName - |
sortPriorities | protected void sortPriorities(ExecPriority[] priotities)(Code) | | |
Methods inherited from com.completex.objective.components.persistency.key.impl.AbstractKeyGenerator | protected void closeAll(Transaction transaction, ResultSet resultSet, PreparedStatement stmt) throws OdalPersistencyException(Code)(Java Doc) public DatabasePolicy getDatabasePolicy()(Code)(Java Doc) public Log getLogger()(Code)(Java Doc) abstract public Object getNextKey(Transaction transaction, Persistency persistency, Record record) throws OdalPersistencyException(Code)(Java Doc) abstract public Object getNextKey(Transaction transaction, Persistency persistency, Record record, Object dynamicParameters) throws OdalPersistencyException(Code)(Java Doc) abstract public Object getNextKeyPlain(Transaction transaction, Persistency persistency, String objectName) throws OdalPersistencyException(Code)(Java Doc) public String getSeqName()(Code)(Java Doc) public Object getStaticParameters()(Code)(Java Doc) abstract public void insertValue(Transaction transaction, Persistency persistency, PersistentEntry persistentEntry) throws OdalPersistencyException(Code)(Java Doc) protected PreparedStatement prepareStatement(Transaction transaction, String sql) throws SQLException(Code)(Java Doc) protected void releaseStatement(Transaction transaction, PreparedStatement statement) throws SQLException(Code)(Java Doc) public void setDatabasePolicy(DatabasePolicy databasePolicy)(Code)(Java Doc) public void setLogger(Log log)(Code)(Java Doc) public void setSeqName(String seqName)(Code)(Java Doc) public void setStaticParameters(Object staticParameters)(Code)(Java Doc) public static Object toConventional(PersistentEntry persistentEntry, Object value)(Code)(Java Doc) abstract public void updateValue(Transaction transaction, Persistency persistency, PersistentEntry persistentEntry, boolean complexDirty) throws OdalPersistencyException(Code)(Java Doc) protected void validate(Transaction transaction)(Code)(Java Doc)
|
|
|