public class SybasePkGenerator extends JdbcPkGenerator
adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue| Modifier | Constructor and Description |
|---|---|
protected |
SybasePkGenerator(JdbcAdapter adapter) |
| Modifier and Type | Method and Description |
|---|---|
void |
createAutoPk(DataNode node,
List<DbEntity> dbEntities)
Generates 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.
|
void |
dropAutoPk(DataNode node,
List<DbEntity> dbEntities)
Drops database objects related to automatic primary key support.
|
List<String> |
dropAutoPkStatements(List<DbEntity> dbEntities)
Returns SQL string needed to drop database objects associated with automatic
primary key generation.
|
protected long |
longPkFromDatabase(DataNode node,
DbEntity entity)
Performs primary key generation ignoring cache.
|
protected String |
pkTableCreateString() |
autoPkTableExists, dropAutoPkString, generatePk, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkUpdateString, reset, runUpdate, setPkCacheSizeprotected SybasePkGenerator(JdbcAdapter adapter)
protected String pkTableCreateString()
pkTableCreateString in class JdbcPkGeneratorpublic void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
1. Executed only if a corresponding table does not exist in the database.
CREATE TABLE AUTO_PK_SUPPORT (
TABLE_NAME VARCHAR(32) NOT NULL,
NEXT_ID DECIMAL(19,0) NOT NULL
)
2. Executed under any circumstances.
if exists (SELECT * FROM sysobjects WHERE name = 'auto_pk_for_table')
BEGIN
DROP PROCEDURE auto_pk_for_table
END
3. Executed under any circumstances.
CREATE PROCEDURE auto_pk_for_table
@tname VARCHAR(32),
@pkbatchsize INT AS BEGIN BEGIN TRANSACTION UPDATE AUTO_PK_SUPPORT set NEXT_ID =
NEXT_ID +
@pkbatchsize WHERE TABLE_NAME =
@tname SELECT NEXT_ID from AUTO_PK_SUPPORT where NEXT_ID =
@tname COMMIT END
createAutoPk 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 JdbcPkGeneratorpublic void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
if exists (SELECT * FROM sysobjects WHERE name = 'AUTO_PK_SUPPORT')
BEGIN
DROP TABLE AUTO_PK_SUPPORT
END
if exists (SELECT * FROM sysobjects WHERE name = 'auto_pk_for_table')
BEGIN
DROP PROCEDURE auto_pk_for_table
END
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)
PkGeneratordropAutoPkStatements in interface PkGeneratordropAutoPkStatements in class JdbcPkGeneratorprotected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception
JdbcPkGeneratorThis method is called internally from "generatePkForDbEntity" and then generated range of key values is saved in cache for performance. Subclasses that implement different primary key generation solutions should override this method, not "generatePkForDbEntity".
longPkFromDatabase in class JdbcPkGeneratorExceptionCopyright © 2001–2023 Apache Cayenne. All rights reserved.