- java.lang.Object
-
- io.ebean.config.dbplatform.SequenceIdGenerator
-
- All Implemented Interfaces:
PlatformIdGenerator
- Direct Known Subclasses:
SequenceBatchIdGenerator,SequenceStepIdGenerator
public abstract class SequenceIdGenerator extends Object implements PlatformIdGenerator
Database sequence based IdGenerator.
-
-
Field Summary
Fields Modifier and Type Field Description protected intallocationSizeprotected BackgroundExecutorbackgroundExecutorprotected AtomicBooleancurrentlyBackgroundLoadingprotected DataSourcedataSourceprotected NavigableSet<Long>idListprotected static org.slf4j.Loggerlogprotected StringseqName-
Fields inherited from interface io.ebean.config.dbplatform.PlatformIdGenerator
AUTO_UUID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int allocationSize)Construct given a dataSource and sql to return the next sequence value.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected List<Long>getMoreIds(int requestSize)Get more Id's by executing a query and reading the Id's returned.StringgetName()Returns the sequence name.abstract StringgetSql(int batchSize)booleanisDbSequence()Returns true.protected voidloadInBackground(int requestSize)Load another batch of Id's using a background thread.ObjectnextId(Transaction t)Return the next Id.voidpreAllocateIds(int requestSize)If allocateSize is large load some sequences in a background thread.protected abstract List<Long>readIds(ResultSet resultSet, int loadSize)Read the resultSet returning the list of Id values.
-
-
-
Field Detail
-
log
protected static final org.slf4j.Logger log
-
seqName
protected final String seqName
-
dataSource
protected final DataSource dataSource
-
backgroundExecutor
protected final BackgroundExecutor backgroundExecutor
-
idList
protected final NavigableSet<Long> idList
-
allocationSize
protected final int allocationSize
-
currentlyBackgroundLoading
protected AtomicBoolean currentlyBackgroundLoading
-
-
Constructor Detail
-
SequenceIdGenerator
protected SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int allocationSize)
Construct given a dataSource and sql to return the next sequence value.
-
-
Method Detail
-
getSql
public abstract String getSql(int batchSize)
-
getName
public String getName()
Returns the sequence name.- Specified by:
getNamein interfacePlatformIdGenerator
-
isDbSequence
public boolean isDbSequence()
Returns true.- Specified by:
isDbSequencein interfacePlatformIdGenerator
-
preAllocateIds
public void preAllocateIds(int requestSize)
If allocateSize is large load some sequences in a background thread.For example, when inserting a bean with a cascade on a OneToMany with many beans Ebean can call this to ensure .
- Specified by:
preAllocateIdsin interfacePlatformIdGenerator
-
nextId
public Object nextId(Transaction t)
Return the next Id.If a Transaction has been passed in use the Connection from it.
- Specified by:
nextIdin interfacePlatformIdGenerator
-
loadInBackground
protected void loadInBackground(int requestSize)
Load another batch of Id's using a background thread.
-
readIds
protected abstract List<Long> readIds(ResultSet resultSet, int loadSize) throws SQLException
Read the resultSet returning the list of Id values.- Throws:
SQLException
-
-