public class SQLIdGenerator extends PersistentIdGenerator
The generated ids are generally sequential and there will generally not be gaps between ids other than when the service is stopped and restarted.
PersistentIdGenerator| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
CLASS_VERSION
Class version string 
 | 
protected static java.lang.String | 
ERR_HWM_BAD_STATE  | 
protected static java.lang.String | 
ERR_HWM_FAIL  | 
protected static java.lang.String | 
ERR_NULL_DS  | 
protected static java.lang.String | 
ERR_QUERY_TABLE  | 
protected static java.lang.String | 
ERR_RESERVE_BAD_STATE  | 
ERR_ADD_BAD_STATE, ERR_ADD_NULL_SPACE, ERR_READING_BOOTSTRAP_SPACES, STATE_ERROR, STATE_INITIALIZING, STATE_NEW, STATE_RUNNING, WARN_PICKING_DEFAULTERR_BAD_SPACE, ERR_ROLLBACK, ERR_UNSUPPORTED, mSpaces, RESOURCE_BUNDLE_NAME, sResourceBundleSERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description | 
|---|
SQLIdGenerator()
Construct a generator 
 | 
| Modifier and Type | Method and Description | 
|---|---|
protected boolean | 
addPersistentIdSpace(IdSpace pSpace)
Add an id space to the data store. 
 | 
java.lang.String | 
getBatchSizeColumn()
Get property BatchSizeColumn 
 | 
javax.sql.DataSource | 
getDataSource()
Get property  
DataSource | 
java.lang.String | 
getInsertSQL()
Get property  
InsertSQL. | 
java.lang.String | 
getNameColumn()
Get property NameColumn 
 | 
java.lang.String | 
getPrefixColumn()
Get property PrefixColumn 
 | 
java.lang.String | 
getSeedColumn()
Get property SeedColumn 
 | 
java.lang.String | 
getSelectSQL()
Get property  
SelectSQL. | 
java.lang.String | 
getSuffixColumn()
Get property SuffixColumn 
 | 
java.lang.String | 
getTableName()
Get property TableName 
 | 
java.lang.String | 
getUpdateSQL()
Get property  
UpdateSQL. | 
boolean | 
getUseRequiredTransactionMode()
Get property  
useRequiredTransactionMode. | 
protected void | 
initializeIdSpaces()
Initialize the id spaces. 
 | 
protected void | 
removePersistentIdSpaces()
Remove all id spaces from the id generator. 
 | 
protected void | 
reserveSeeds(IdSpace pSpace)
Reserve a batch of seeds for the specified id space. 
 | 
void | 
setBatchSizeColumn(java.lang.String pBatchSizeColumn)
Set property BatchSizeColumn 
 | 
void | 
setDataSource(javax.sql.DataSource pDataSource)
Set property  
DataSource | 
void | 
setHighWaterMark(java.lang.String pIdSpaceName,
                long pHighWaterMark)
Set the high water mark for the specified id space. 
 | 
void | 
setNameColumn(java.lang.String pNameColumn)
Set property NameColumn 
 | 
void | 
setPrefixColumn(java.lang.String pPrefixColumn)
Set property PrefixColumn 
 | 
void | 
setSeedColumn(java.lang.String pSeedColumn)
Set property SeedColumn 
 | 
void | 
setSuffixColumn(java.lang.String pSuffixColumn)
Set property SuffixColumn 
 | 
void | 
setTableName(java.lang.String pTableName)
Set property TableName 
 | 
void | 
setUseRequiredTransactionMode(boolean pUseRequiredTransactionMode)
Set property  
useRequiredTransactionMode. | 
addIdSpace, getInitialIdSpaces, getLoadInitialIdSpacesAtStartup, getState, getTransactionManager, getXMLToolsFactory, initialize, removeAllIdSpaces, removeIdSpace, setInitialIdSpaces, setLoadInitialIdSpacesAtStartup, setState, setTransactionManager, setXMLToolsFactorydoStartService, format, format, format, format, generateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getBundle, getDefaultIdSpace, getDefaultIdSpaceName, getIdSpace, getIdSpaces, getResourceBundleName, isAutoCreate, postGenerateLongId, postGenerateStringId, setAutoCreate, setDefaultIdSpace, setDefaultIdSpaceName, toStringaddLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgenerateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getDefaultIdSpace, getIdSpace, getIdSpaces, isAutoCreate, setAutoCreatepublic static java.lang.String CLASS_VERSION
protected static java.lang.String ERR_HWM_BAD_STATE
protected static java.lang.String ERR_HWM_FAIL
protected static java.lang.String ERR_NULL_DS
protected static java.lang.String ERR_QUERY_TABLE
protected static java.lang.String ERR_RESERVE_BAD_STATE
public void setTableName(java.lang.String pTableName)
pTableName - new value to setpublic java.lang.String getTableName()
public void setNameColumn(java.lang.String pNameColumn)
pNameColumn - new value to setpublic java.lang.String getNameColumn()
public void setSeedColumn(java.lang.String pSeedColumn)
pSeedColumn - new value to setpublic java.lang.String getSeedColumn()
public void setBatchSizeColumn(java.lang.String pBatchSizeColumn)
pBatchSizeColumn - new value to setpublic java.lang.String getBatchSizeColumn()
public void setPrefixColumn(java.lang.String pPrefixColumn)
pPrefixColumn - new value to setpublic java.lang.String getPrefixColumn()
public void setSuffixColumn(java.lang.String pSuffixColumn)
pSuffixColumn - new value to setpublic java.lang.String getSuffixColumn()
public void setDataSource(javax.sql.DataSource pDataSource)
DataSourcepDataSource - new value to setpublic javax.sql.DataSource getDataSource()
DataSourceDataSourcepublic java.lang.String getSelectSQL()
SelectSQL. The SQL is lazily generated.public java.lang.String getInsertSQL()
InsertSQL. The SQL is lazily generated.public java.lang.String getUpdateSQL()
UpdateSQL. The SQL is lazily generated.public void setUseRequiredTransactionMode(boolean pUseRequiredTransactionMode)
useRequiredTransactionMode. This is a flag
 which, if true indicates that REQUIRED
 transaction mode should be used when the batch size is 1 to prevent gaps
 in id sequences. Normalay REQUIRES_NEW transaction mode is
 used. REQUIRED mode is only used if the batch size is 1 and
 this flag is true. This flag defaults to
 false. Setting this flag to true can
 potentially lead to deadlocks, so use it with caution.pUseRequiredTransactionMode - new value to setpublic boolean getUseRequiredTransactionMode()
useRequiredTransactionMode. This is a flag
 which, if true indicates that REQUIRED
 transaction mode should be used when the batch size is 1 to prevent gaps
 in id sequences. Normalay REQUIRES_NEW transaction mode is
 used. REQUIRED mode is only used if the batch size is 1 and
 this flag is true. This flag defaults to
 false. Setting this flag to true can
 potentially lead to deadlocks, so use it with caution.useRequiredTransactionModeprotected boolean addPersistentIdSpace(IdSpace pSpace) throws IdGeneratorException
addPersistentIdSpace in class PersistentIdGeneratorpSpace - space to add, cannot be null. Nota Bene: this may be
 modified by this method.IdGeneratorException - if there is trouble adding id spaceprotected void removePersistentIdSpaces()
                                 throws IdGeneratorException
IdGeneratorException - if there is DB troubleprotected void initializeIdSpaces()
                           throws IdGeneratorException
TableName. If that fails it tries to insert the
 default id space into the table. If that fails this method gives up.This method is guaranteed to put at least one id space in the list if no exception is thrown.
initializeIdSpaces in class PersistentIdGeneratorIdGeneratorException - if there is an error
 initializing. If initialization was unsuccessful the
 IdGeneratorException may have a source exception which is a chain
 of all of the SQLExceptions encountered during the attempt to initializeprotected void reserveSeeds(IdSpace pSpace) throws IdGeneratorException
DataSource for use and closes that
 connection when done. This method also runs in its own new transaction.reserveSeeds in class PersistentIdGeneratorpSpace - id space to reserve seeds in, cannot be nullIdGeneratorException - if there is DB troublepublic void setHighWaterMark(java.lang.String pIdSpaceName,
                    long pHighWaterMark)
                      throws IdGeneratorException
setHighWaterMark in class AbstractSequentialIdGeneratorpIdSpaceName - name of id space to usepHighWaterMark - high water mark to setIdGeneratorException - if the id generator cannot guarantee
 that the specified high water mark can be set