java.lang.Object
io.ebean.config.dbplatform.SequenceIdGenerator
- All Implemented Interfaces:
PlatformIdGenerator
- Direct Known Subclasses:
SequenceBatchIdGenerator
,SequenceStepIdGenerator
Database sequence based IdGenerator.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final BackgroundExecutor
protected AtomicBoolean
protected final DataSource
protected final NavigableSet<Long>
protected static final org.slf4j.Logger
protected final String
Fields inherited from interface io.ebean.config.dbplatform.PlatformIdGenerator
AUTO_UUID
-
Constructor Summary
ModifierConstructorDescriptionprotected
SequenceIdGenerator
(BackgroundExecutor be, DataSource ds, String seqName, int allocationSize) Construct given a dataSource and sql to return the next sequence value. -
Method Summary
Modifier and TypeMethodDescriptiongetMoreIds
(int requestSize) Get more Id's by executing a query and reading the Id's returned.getName()
Returns the sequence name.abstract String
getSql
(int batchSize) boolean
Returns true.protected void
loadInBackground
(int requestSize) Load another batch of Id's using a background thread.Return the next Id.void
preAllocateIds
(int requestSize) If allocateSize is large load some sequences in a background thread.Read the resultSet returning the list of Id values.
-
Field Details
-
log
protected static final org.slf4j.Logger log -
seqName
-
dataSource
-
backgroundExecutor
-
idList
-
allocationSize
protected final int allocationSize -
currentlyBackgroundLoading
-
-
Constructor Details
-
SequenceIdGenerator
protected SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int allocationSize) Construct given a dataSource and sql to return the next sequence value.
-
-
Method Details
-
getSql
-
getName
Returns the sequence name.- Specified by:
getName
in interfacePlatformIdGenerator
-
isDbSequence
public boolean isDbSequence()Returns true.- Specified by:
isDbSequence
in 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:
preAllocateIds
in interfacePlatformIdGenerator
-
nextId
Return the next Id.If a Transaction has been passed in use the Connection from it.
- Specified by:
nextId
in interfacePlatformIdGenerator
-
loadInBackground
protected void loadInBackground(int requestSize) Load another batch of Id's using a background thread. -
readIds
Read the resultSet returning the list of Id values.- Throws:
SQLException
-
getMoreIds
Get more Id's by executing a query and reading the Id's returned.
-