java.lang.Object
org.objectstyle.cayenne.dba.JdbcPkGenerator
org.objectstyle.cayenne.dba.oracle.OraclePkGenerator
- All Implemented Interfaces:
- org.objectstyle.cayenne.dba.PkGenerator
- public class OraclePkGenerator
- extends org.objectstyle.cayenne.dba.JdbcPkGenerator
Sequence-based primary key generator implementation for Oracle.
Uses Oracle sequences to generate primary key values. This approach is
at least 50% faster when tested with Oracle compared to the lookup table
approach.
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);
| 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 |
_SEQUENCE_PREFIX
private static final java.lang.String _SEQUENCE_PREFIX
- See Also:
- Constant Field Values
OraclePkGenerator
public OraclePkGenerator()
createAutoPk
public void createAutoPk(org.objectstyle.cayenne.access.DataNode node,
java.util.List dbEntities)
throws java.lang.Exception
- Description copied from interface:
org.objectstyle.cayenne.dba.PkGenerator
- Generates necessary database objects to provide automatic primary
key support.
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
- Description copied from class:
org.objectstyle.cayenne.dba.JdbcPkGenerator
- Drops table named "AUTO_PK_SUPPORT" if it exists in the
database.
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.
createSequenceString
protected java.lang.String createSequenceString(org.objectstyle.cayenne.map.DbEntity ent)
dropSequenceString
protected java.lang.String dropSequenceString(org.objectstyle.cayenne.map.DbEntity ent)
- Returns a SQL string needed to drop any database objects associated
with automatic primary key generation process for a specific DbEntity.
pkFromDatabase
protected int pkFromDatabase(org.objectstyle.cayenne.access.DataNode node,
org.objectstyle.cayenne.map.DbEntity ent)
throws java.lang.Exception
- Generates primary key by calling Oracle sequence corresponding to the
dbEntity. Executed SQL looks like this:
SELECT pk_table_name.nextval FROM DUAL
pkCacheSize
protected int pkCacheSize(org.objectstyle.cayenne.map.DbEntity entity)
sequenceName
protected java.lang.String sequenceName(org.objectstyle.cayenne.map.DbEntity entity)
- Returns expected primary key sequence name for a DbEntity.
stripSchemaName
protected java.lang.String stripSchemaName(java.lang.String sequenceName)
getExistingSequences
protected java.util.List getExistingSequences(org.objectstyle.cayenne.access.DataNode node)
throws java.sql.SQLException
- Fetches a list of existing sequences that might match Cayenne
generated ones.