Package org.apache.cayenne.dba.sqlserver
Class SQLServerPkGenerator
java.lang.Object
org.apache.cayenne.dba.JdbcPkGenerator
org.apache.cayenne.dba.oracle.OraclePkGenerator
org.apache.cayenne.dba.sqlserver.SQLServerPkGenerator
- All Implemented Interfaces:
PkGenerator
The default PK generator for MS SQL,
which uses sequences to generate a PK for an integer key type
and NEWID() for UNIQUEIDENTIFIER key type
- Since:
- 4.1
-
Field Summary
Fields inherited from class org.apache.cayenne.dba.JdbcPkGenerator
adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateAutoPkStatements
(List<DbEntity> dbEntities) Creates a list of CREATE SEQUENCE statements for the list of DbEntities.protected String
dropAutoPkStatements
(List<DbEntity> dbEntities) Creates a list of DROP SEQUENCE statements for the list of DbEntities.generatePk
(DataNode node, DbAttribute pk) Generates a unique and non-repeating primary key for specified dbEntity.protected String
protected String
guidPkFromDatabase
(DataNode node, DbEntity entity) protected String
protected String
selectNextValQuery
(String sequenceName) protected String
sequenceName
(DbEntity entity) Returns expected primary key sequence name for a DbEntity.Methods inherited from class org.apache.cayenne.dba.oracle.OraclePkGenerator
createAutoPk, dropAutoPk, dropSequenceString, getExistingSequences, longPkFromDatabase, pkCacheSize
Methods inherited from class org.apache.cayenne.dba.JdbcPkGenerator
autoPkTableExists, dropAutoPkString, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runUpdate, setAdapter, setPkCacheSize
-
Constructor Details
-
SQLServerPkGenerator
public SQLServerPkGenerator() -
SQLServerPkGenerator
-
-
Method Details
-
createSequenceString
- Overrides:
createSequenceString
in classOraclePkGenerator
-
getSequencePrefix
- Overrides:
getSequencePrefix
in classOraclePkGenerator
-
selectNextValQuery
- Overrides:
selectNextValQuery
in classOraclePkGenerator
-
createAutoPkStatements
Description copied from class:OraclePkGenerator
Creates a list of CREATE SEQUENCE statements for the list of DbEntities.- Specified by:
createAutoPkStatements
in interfacePkGenerator
- Overrides:
createAutoPkStatements
in classOraclePkGenerator
-
dropAutoPkStatements
Description copied from class:OraclePkGenerator
Creates a list of DROP SEQUENCE statements for the list of DbEntities.- Specified by:
dropAutoPkStatements
in interfacePkGenerator
- Overrides:
dropAutoPkStatements
in classOraclePkGenerator
-
generatePk
Description copied from class:JdbcPkGenerator
Generates a unique and non-repeating primary key for specified dbEntity.This implementation is naive since it does not lock the database rows when executing select and subsequent update. Adapter-specific implementations are more robust.
- Specified by:
generatePk
in interfacePkGenerator
- Overrides:
generatePk
in classJdbcPkGenerator
- Throws:
Exception
-
selectAllSequencesQuery
- Overrides:
selectAllSequencesQuery
in classOraclePkGenerator
-
sequenceName
Description copied from class:OraclePkGenerator
Returns expected primary key sequence name for a DbEntity.- Overrides:
sequenceName
in classOraclePkGenerator
-
guidPkFromDatabase
- Throws:
SQLException
-