public class OraclePkGenerator extends JdbcPkGenerator
When using Cayenne key caching mechanism, make sure that sequences in the database have "INCREMENT BY" greater or equal to OraclePkGenerator "pkCacheSize" property value. If this is not the case, you will need to adjust PkGenerator value accordingly. For example when sequence is incremented by 1 each time, use the following code:
dataNode.getAdapter().getPkGenerator().setPkCacheSize(1);
adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue| Modifier | Constructor and Description |
|---|---|
protected |
OraclePkGenerator(JdbcAdapter adapter) |
| Modifier and Type | Method and Description |
|---|---|
void |
createAutoPk(DataNode node,
List<DbEntity> dbEntities)
Generates necessary database objects to provide automatic primary key support.
|
List<String> |
createAutoPkStatements(List<DbEntity> dbEntities)
Creates a list of CREATE SEQUENCE statements for the list of DbEntities.
|
protected String |
createSequenceString(DbEntity ent) |
void |
dropAutoPk(DataNode node,
List<DbEntity> dbEntities)
Drops PK sequences for all specified DbEntities.
|
List<String> |
dropAutoPkStatements(List<DbEntity> dbEntities)
Creates a list of DROP SEQUENCE statements for the list of DbEntities.
|
protected String |
dropSequenceString(DbEntity ent)
Returns a SQL string needed to drop any database objects associated with
automatic primary key generation process for a specific DbEntity.
|
protected List<String> |
getExistingSequences(DataNode node)
Fetches a list of existing sequences that might match Cayenne generated
ones.
|
protected String |
getSequencePrefix() |
protected long |
longPkFromDatabase(DataNode node,
DbEntity entity)
Generates primary key by calling Oracle sequence corresponding to the
dbEntity. |
protected int |
pkCacheSize(DbEntity entity) |
protected String |
selectAllSequencesQuery() |
protected String |
selectNextValQuery(String pkGeneratingSequenceName) |
protected String |
sequenceName(DbEntity entity)
Returns expected primary key sequence name for a DbEntity.
|
autoPkTableExists, dropAutoPkString, generatePk, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runUpdate, setPkCacheSizeprotected OraclePkGenerator(JdbcAdapter adapter)
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)
createAutoPkStatements in interface PkGeneratorcreateAutoPkStatements in class JdbcPkGeneratorpublic void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
dropAutoPk 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 dropSequenceString(DbEntity ent)
protected String selectAllSequencesQuery()
protected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception
dbEntity. Executed SQL looks like this:
SELECT pk_table_name.nextval FROM DUAL
longPkFromDatabase in class JdbcPkGeneratorExceptionprotected int pkCacheSize(DbEntity entity)
protected String sequenceName(DbEntity entity)
protected String getSequencePrefix()
protected List<String> getExistingSequences(DataNode node) throws SQLException
SQLExceptionCopyright © 2001–2023 Apache Cayenne. All rights reserved.