java.lang.Object
org.objectstyle.cayenne.dba.JdbcPkGenerator
org.objectstyle.cayenne.dba.sybase.SybasePkGenerator
- All Implemented Interfaces:
- org.objectstyle.cayenne.dba.PkGenerator
- public class SybasePkGenerator
- extends org.objectstyle.cayenne.dba.JdbcPkGenerator
Primary key generator implementation for Sybase. Uses a lookup table named
"AUTO_PK_SUPPORT" and a stored procedure "auto_pk_for_table"
to search and increment primary keys for tables.
| Nested classes inherited from class org.objectstyle.cayenne.dba.JdbcPkGenerator |
org.objectstyle.cayenne.dba.JdbcPkGenerator.PkRetrieveProcessor |
| Methods inherited from class org.objectstyle.cayenne.dba.JdbcPkGenerator |
autoPkTableExists, dropAutoPkString, generatePkForDbEntity, generatePkForDbEntityString, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runSelect, runUpdate, setPkCacheSize |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SybasePkGenerator
public SybasePkGenerator()
createAutoPk
public void createAutoPk(org.objectstyle.cayenne.access.DataNode node,
java.util.List dbEntities)
throws java.lang.Exception
- Generates database objects to provide
automatic primary key support. Method will execute the following
SQL statements:
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 INTEGER 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
createAutoPkStatements
public java.util.List createAutoPkStatements(java.util.List dbEntities)
- Description copied from interface:
org.objectstyle.cayenne.dba.PkGenerator
- Returns 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.
dropAutoPk
public void dropAutoPk(org.objectstyle.cayenne.access.DataNode node,
java.util.List dbEntities)
throws java.lang.Exception
- Drops database objects related to automatic primary
key support. Method will execute the following SQL
statements:
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
dropAutoPkStatements
public java.util.List dropAutoPkStatements(java.util.List dbEntities)
- Description copied from interface:
org.objectstyle.cayenne.dba.PkGenerator
- Returns SQL string needed to drop database objects associated
with automatic primary key generation. No actual database
operations are performed.
pkFromDatabase
protected int pkFromDatabase(org.objectstyle.cayenne.access.DataNode node,
org.objectstyle.cayenne.map.DbEntity ent)
throws java.lang.Exception
- Description copied from class:
org.objectstyle.cayenne.dba.JdbcPkGenerator
- Performs primary key generation ignoring cache. Generates
a range of primary keys as specified by
"pkCacheSize" bean property.
This 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".
safePkTableDrop
private java.lang.String safePkTableDrop()
unsafePkProcCreate
private java.lang.String unsafePkProcCreate()
safePkProcDrop
private java.lang.String safePkProcDrop()