|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.dba.JdbcPkGenerator
org.apache.cayenne.dba.oracle.OraclePkGenerator
public class OraclePkGenerator
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);
Field Summary |
---|
Fields inherited from class org.apache.cayenne.dba.JdbcPkGenerator |
---|
DEFAULT_PK_CACHE_SIZE, NEXT_ID, objDesc, pkCache, pkCacheSize, resultDesc |
Constructor Summary | |
---|---|
OraclePkGenerator()
|
Method Summary | |
---|---|
void |
createAutoPk(DataNode node,
java.util.List dbEntities)
Generates necessary database objects to provide automatic primary key support. |
java.util.List |
createAutoPkStatements(java.util.List dbEntities)
Returns a list of SQL strings needed to generates database objects to provide automatic primary support for the list of entities. |
protected java.lang.String |
createSequenceString(DbEntity ent)
|
void |
dropAutoPk(DataNode node,
java.util.List dbEntities)
Drops table named "AUTO_PK_SUPPORT" if it exists in the database. |
java.util.List |
dropAutoPkStatements(java.util.List dbEntities)
Returns SQL string needed to drop database objects associated with automatic primary key generation. |
protected java.lang.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 java.util.List |
getExistingSequences(DataNode node)
Fetches a list of existing sequences that might match Cayenne generated ones. |
protected int |
pkCacheSize(DbEntity entity)
|
protected int |
pkFromDatabase(DataNode node,
DbEntity ent)
Generates primary key by calling Oracle sequence corresponding to the dbEntity . |
protected java.lang.String |
sequenceName(DbEntity entity)
Returns expected primary key sequence name for a DbEntity. |
protected java.lang.String |
stripSchemaName(java.lang.String sequenceName)
|
Methods inherited from class org.apache.cayenne.dba.JdbcPkGenerator |
---|
autoPkTableExists, binaryPK, dropAutoPkString, generatePkForDbEntity, generatePkForDbEntityString, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runUpdate, setPkCacheSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OraclePkGenerator()
Method Detail |
---|
public void createAutoPk(DataNode node, java.util.List dbEntities) throws java.lang.Exception
PkGenerator
createAutoPk
in interface PkGenerator
createAutoPk
in class JdbcPkGenerator
node
- node that provides access to a DataSource.dbEntities
- a list of entities that require primary key autogeneration
support
java.lang.Exception
public java.util.List createAutoPkStatements(java.util.List dbEntities)
PkGenerator
createAutoPkStatements
in interface PkGenerator
createAutoPkStatements
in class JdbcPkGenerator
public void dropAutoPk(DataNode node, java.util.List dbEntities) throws java.lang.Exception
JdbcPkGenerator
dropAutoPk
in interface PkGenerator
dropAutoPk
in class JdbcPkGenerator
node
- node that provides access to a DataSource.dbEntities
- a list of entities whose primary key autogeneration support
should be dropped.
java.lang.Exception
public java.util.List dropAutoPkStatements(java.util.List dbEntities)
PkGenerator
dropAutoPkStatements
in interface PkGenerator
dropAutoPkStatements
in class JdbcPkGenerator
protected java.lang.String createSequenceString(DbEntity ent)
protected java.lang.String dropSequenceString(DbEntity ent)
protected int pkFromDatabase(DataNode node, DbEntity ent) throws java.lang.Exception
dbEntity
. Executed SQL looks like this:
SELECT pk_table_name.nextval FROM DUAL
pkFromDatabase
in class JdbcPkGenerator
java.lang.Exception
protected int pkCacheSize(DbEntity entity)
protected java.lang.String sequenceName(DbEntity entity)
protected java.lang.String stripSchemaName(java.lang.String sequenceName)
protected java.util.List getExistingSequences(DataNode node) throws java.sql.SQLException
java.sql.SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |