public class OpenBasePkGenerator extends JdbcPkGenerator
adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue| Modifier | Constructor and Description |
|---|---|
protected |
OpenBasePkGenerator(JdbcAdapter adapter) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canCreatePK(DbEntity entity) |
void |
createAutoPk(DataNode node,
List<DbEntity> dbEntities)
Generates necessary database objects to provide automatic primary key support.
|
List<String> |
createAutoPkStatements(List<DbEntity> dbEntities)
Returns a list of SQL strings needed to generates database objects to provide
automatic primary support for the list of entities.
|
protected String |
createPKString(DbEntity entity)
Returns a String to create PK support for an entity.
|
protected String |
createUniquePKIndexString(DbEntity entity)
Returns a String to create a unique index on table primary key columns
per OpenBase recommendations.
|
void |
dropAutoPk(DataNode node,
List<DbEntity> dbEntities)
Drops table named "AUTO_PK_SUPPORT" if it exists in the database.
|
List<String> |
dropAutoPkStatements(List<DbEntity> dbEntities)
Returns an empty list, since OpenBase doesn't support this operation.
|
Object |
generatePk(DataNode node,
DbAttribute pk)
Returns a non-repeating primary key for a given PK attribute.
|
int |
getPkCacheSize()
Returns zero, since PK caching is not feasible with OpenBase PK
generation mechanism.
|
protected long |
longPkFromDatabase(DataNode node,
DbEntity entity)
Generates new (unique and non-repeating) primary key for specified
DbEntity.
|
protected String |
newIDString(DbEntity ent)
Returns SQL string that can generate new (unique and non-repeating)
primary key for specified DbEntity.
|
void |
reset()
Resets any cached primary keys forcing generator to go to the database next time id
generation is requested.
|
void |
setPkCacheSize(int pkCacheSize)
Sets the size of the entity primary key cache.
|
autoPkTableExists, dropAutoPkString, getAdapter, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, runUpdateprotected OpenBasePkGenerator(JdbcAdapter adapter)
public Object generatePk(DataNode node, DbAttribute pk) throws Exception
generatePk in interface PkGeneratorgeneratePk in class JdbcPkGeneratorExceptionprotected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception
NEWID FOR Table ColumnCOLUMN must be marked as UNIQUE in order for this to work properly.
longPkFromDatabase in class JdbcPkGeneratorExceptionprotected String newIDString(DbEntity ent)
public void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
PkGeneratorcreateAutoPk in interface PkGeneratorcreateAutoPk in class JdbcPkGeneratornode - node that provides access to a DataSource.dbEntities - a list of entities that require primary key auto-generation
supportExceptionpublic List<String> createAutoPkStatements(List<DbEntity> dbEntities)
PkGeneratorcreateAutoPkStatements in interface PkGeneratorcreateAutoPkStatements in class JdbcPkGeneratorprotected boolean canCreatePK(DbEntity entity)
public void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
JdbcPkGeneratordropAutoPk in interface PkGeneratordropAutoPk in class JdbcPkGeneratornode - node that provides access to a DataSource.dbEntities - a list of entities whose primary key auto-generation support
should be dropped.Exceptionpublic List<String> dropAutoPkStatements(List<DbEntity> dbEntities)
dropAutoPkStatements in interface PkGeneratordropAutoPkStatements in class JdbcPkGeneratorprotected String createPKString(DbEntity entity)
protected String createUniquePKIndexString(DbEntity entity)
public void reset()
PkGeneratorreset in interface PkGeneratorreset in class JdbcPkGeneratorpublic int getPkCacheSize()
getPkCacheSize in class JdbcPkGeneratorpublic void setPkCacheSize(int pkCacheSize)
JdbcPkGeneratorpkCacheSize parameter is less than 1, cache size is set to
"one".
Note that our tests show that setting primary key cache value to anything much bigger than 20 does not give any significant performance increase. Therefore it does not make sense to use bigger values, since this may potentially create big gaps in the database primary key sequences in cases like application crashes or restarts.
setPkCacheSize in class JdbcPkGeneratorCopyright © 2001–2023 Apache Cayenne. All rights reserved.