public abstract class SequenceIdGenerator extends Object implements PlatformIdGenerator
| Modifier and Type | Field and Description |
|---|---|
protected BackgroundExecutor |
backgroundExecutor |
protected Object |
backgroundLoadMonitor
Used to synchronise background loading (loadBatchInBackground).
|
protected int |
batchSize |
protected int |
currentlyBackgroundLoading |
protected DataSource |
dataSource |
protected ArrayList<Long> |
idList |
protected Object |
monitor
Used to synchronise the idList access.
|
protected String |
seqName
The actual sequence name.
|
AUTO_UUID| Constructor and Description |
|---|
SequenceIdGenerator(BackgroundExecutor be,
DataSource ds,
String seqName,
int batchSize)
Construct given a dataSource and sql to return the next sequence value.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeResources(Connection c,
PreparedStatement pstmt,
ResultSet rset)
Close the JDBC resources.
|
protected ArrayList<Long> |
getMoreIds(int loadSize,
Transaction t)
Get more Id's by executing a query and reading the Id's returned.
|
String |
getName()
Returns the sequence name.
|
abstract String |
getSql(int batchSize) |
boolean |
isDbSequence()
Returns true.
|
protected void |
loadBatchInBackground()
Load another batch of Id's using a background thread.
|
protected void |
loadLargeAllocation(int allocateSize)
Called by preAllocateIds when we know that a large number of Id's is going
to be needed shortly.
|
protected void |
loadMoreIds(int numberToLoad,
Transaction t) |
Object |
nextId(Transaction t)
Return the next Id.
|
void |
preAllocateIds(int allocateSize)
If allocateSize is large load some sequences in a background thread.
|
protected final Object backgroundLoadMonitor
protected final DataSource dataSource
protected final BackgroundExecutor backgroundExecutor
protected final int batchSize
protected int currentlyBackgroundLoading
public SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize)
public String getName()
getName in interface PlatformIdGeneratorpublic boolean isDbSequence()
isDbSequence in interface PlatformIdGeneratorpublic void preAllocateIds(int allocateSize)
For example, when inserting a bean with a cascade on a OneToMany with many beans Ebean can call this to ensure .
preAllocateIds in interface PlatformIdGeneratorprotected void loadLargeAllocation(int allocateSize)
public Object nextId(Transaction t)
If a Transaction has been passed in use the Connection from it.
nextId in interface PlatformIdGeneratorprotected void loadBatchInBackground()
protected void loadMoreIds(int numberToLoad, Transaction t)
protected ArrayList<Long> getMoreIds(int loadSize, Transaction t)
protected void closeResources(Connection c, PreparedStatement pstmt, ResultSet rset)
Copyright © 2016. All rights reserved.