Package org.apache.cayenne.dba.openbase
Class OpenBasePkGenerator
java.lang.Object
org.apache.cayenne.dba.JdbcPkGenerator
org.apache.cayenne.dba.openbase.OpenBasePkGenerator
- All Implemented Interfaces:
- PkGenerator
public class OpenBasePkGenerator extends JdbcPkGenerator
- Since:
- 1.1
- 
Field SummaryFields inherited from class org.apache.cayenne.dba.JdbcPkGeneratoradapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue
- 
Constructor SummaryConstructors Modifier Constructor Description OpenBasePkGenerator()Used by DIprotectedOpenBasePkGenerator(JdbcAdapter adapter)
- 
Method SummaryModifier and Type Method Description protected booleancanCreatePK(DbEntity entity)voidcreateAutoPk(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 StringcreatePKString(DbEntity entity)Returns a String to create PK support for an entity.protected StringcreateUniquePKIndexString(DbEntity entity)Returns a String to create a unique index on table primary key columns per OpenBase recommendations.voiddropAutoPk(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.ObjectgeneratePk(DataNode node, DbAttribute pk)Returns a non-repeating primary key for a given PK attribute.intgetPkCacheSize()Returns zero, since PK caching is not feasible with OpenBase PK generation mechanism.protected longlongPkFromDatabase(DataNode node, DbEntity entity)Generates new (unique and non-repeating) primary key for specified DbEntity.protected StringnewIDString(DbEntity ent)Returns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity.voidreset()Resets any cached primary keys forcing generator to go to the database next time id generation is requested.voidsetPkCacheSize(int pkCacheSize)Sets the size of the entity primary key cache.Methods inherited from class org.apache.cayenne.dba.JdbcPkGeneratorautoPkTableExists, dropAutoPkString, getAdapter, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, runUpdate, setAdapter
- 
Constructor Details- 
OpenBasePkGeneratorpublic OpenBasePkGenerator()Used by DI- Since:
- 4.1
 
- 
OpenBasePkGenerator
 
- 
- 
Method Details- 
generatePkReturns a non-repeating primary key for a given PK attribute. Since OpenBase-specific mechanism is used, key caching is disabled. Instead a database operation is performed on every call.- Specified by:
- generatePkin interface- PkGenerator
- Overrides:
- generatePkin class- JdbcPkGenerator
- Throws:
- Exception
- Since:
- 3.0
 
- 
longPkFromDatabaseGenerates new (unique and non-repeating) primary key for specified DbEntity. Executed SQL looks like this:NEWID FOR Table Column COLUMN must be marked as UNIQUE in order for this to work properly. - Overrides:
- longPkFromDatabasein class- JdbcPkGenerator
- Throws:
- Exception
- Since:
- 3.0
 
- 
newIDStringReturns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity. No actual database operations are performed.- Since:
- 1.2
 
- 
createAutoPkDescription copied from interface:PkGeneratorGenerates necessary database objects to provide automatic primary key support.- Specified by:
- createAutoPkin interface- PkGenerator
- Overrides:
- createAutoPkin class- JdbcPkGenerator
- Parameters:
- node- node that provides access to a DataSource.
- dbEntities- a list of entities that require primary key auto-generation support
- Throws:
- Exception
 
- 
createAutoPkStatementsDescription copied from interface:PkGeneratorReturns a list of SQL strings needed to generates database objects to provide automatic primary support for the list of entities. No actual database operations are performed.- Specified by:
- createAutoPkStatementsin interface- PkGenerator
- Overrides:
- createAutoPkStatementsin class- JdbcPkGenerator
 
- 
canCreatePK
- 
dropAutoPkDescription copied from class:JdbcPkGeneratorDrops table named "AUTO_PK_SUPPORT" if it exists in the database.- Specified by:
- dropAutoPkin interface- PkGenerator
- Overrides:
- dropAutoPkin class- JdbcPkGenerator
- Parameters:
- node- node that provides access to a DataSource.
- dbEntities- a list of entities whose primary key auto-generation support should be dropped.
- Throws:
- Exception
 
- 
dropAutoPkStatementsReturns an empty list, since OpenBase doesn't support this operation.- Specified by:
- dropAutoPkStatementsin interface- PkGenerator
- Overrides:
- dropAutoPkStatementsin class- JdbcPkGenerator
 
- 
createPKStringReturns a String to create PK support for an entity.
- 
createUniquePKIndexStringReturns a String to create a unique index on table primary key columns per OpenBase recommendations.
- 
resetpublic void reset()Description copied from interface:PkGeneratorResets any cached primary keys forcing generator to go to the database next time id generation is requested. May not be applicable for all generator implementations.- Specified by:
- resetin interface- PkGenerator
- Overrides:
- resetin class- JdbcPkGenerator
 
- 
getPkCacheSizepublic int getPkCacheSize()Returns zero, since PK caching is not feasible with OpenBase PK generation mechanism.- Overrides:
- getPkCacheSizein class- JdbcPkGenerator
 
- 
setPkCacheSizepublic void setPkCacheSize(int pkCacheSize)Description copied from class:JdbcPkGeneratorSets the size of the entity primary key cache. IfpkCacheSizeparameter 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. - Overrides:
- setPkCacheSizein class- JdbcPkGenerator
 
 
-