|
|||||||||
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.openbase.OpenBasePkGenerator
public class OpenBasePkGenerator
Field Summary |
---|
Fields inherited from class org.apache.cayenne.dba.JdbcPkGenerator |
---|
DEFAULT_PK_CACHE_SIZE, NEXT_ID, objDesc, pkCache, pkCacheSize, resultDesc |
Constructor Summary | |
---|---|
OpenBasePkGenerator()
|
Method Summary | |
---|---|
protected boolean |
canCreatePK(DbEntity entity)
|
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 |
createPKString(DbEntity entity)
Returns a String to create PK support for an entity. |
protected java.lang.String |
createUniquePKIndexString(DbEntity entity)
Returns a String to create a unique index on table primary key columns per OpenBase recommendations. |
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 an empty list, since OpenBase doesn't support this operation. |
java.lang.Object |
generatePkForDbEntity(DataNode node,
DbEntity entity)
Returns a non-repeating primary key for a given entity. |
java.lang.String |
generatePkForDbEntityString(DbEntity ent)
Deprecated. Since 1.2 corresponding interface method is unused and deprecated. |
int |
getPkCacheSize()
Returns zero, since PK caching is not feasible with OpenBase PK generation mechanism. |
protected java.lang.String |
newIDString(DbEntity ent)
Returns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity. |
protected int |
pkFromDatabase(DataNode node,
DbEntity entity)
Generates new (unique and non-repeating) primary key for specified DbEntity. |
void |
reset()
Resets any cached primary keys forcing generator to go to the database next time id generation is requested. |
void |
setPkCacheSize(int pkCacheSize)
Sets the size of the entity primary key cache. |
Methods inherited from class org.apache.cayenne.dba.JdbcPkGenerator |
---|
autoPkTableExists, binaryPK, dropAutoPkString, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, runUpdate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OpenBasePkGenerator()
Method Detail |
---|
public java.lang.String generatePkForDbEntityString(DbEntity ent)
PkGenerator
generatePkForDbEntityString
in interface PkGenerator
generatePkForDbEntityString
in class JdbcPkGenerator
public java.lang.Object generatePkForDbEntity(DataNode node, DbEntity entity) throws java.lang.Exception
generatePkForDbEntity
in interface PkGenerator
generatePkForDbEntity
in class JdbcPkGenerator
entity
- DbEntity for which automatic PK is generated.
java.lang.Exception
protected int pkFromDatabase(DataNode node, DbEntity entity) throws java.lang.Exception
NEWID FOR Table ColumnCOLUMN must be marked as UNIQUE in order for this to work properly.
pkFromDatabase
in class JdbcPkGenerator
java.lang.Exception
protected java.lang.String newIDString(DbEntity ent)
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
protected boolean canCreatePK(DbEntity entity)
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)
dropAutoPkStatements
in interface PkGenerator
dropAutoPkStatements
in class JdbcPkGenerator
protected java.lang.String createPKString(DbEntity entity)
protected java.lang.String createUniquePKIndexString(DbEntity entity)
public void reset()
PkGenerator
reset
in interface PkGenerator
reset
in class JdbcPkGenerator
public int getPkCacheSize()
getPkCacheSize
in class JdbcPkGenerator
public void setPkCacheSize(int pkCacheSize)
JdbcPkGenerator
pkCacheSize
parameter is less than 1, cache size is set to "one".
Note that our tests show that setting primary key cache value to anything much bigger than 20 does not give any significant performance increase. Therefore it does not make sense to use bigger values, since this may potentially create big gaps in the database primary key sequences in cases like application crashes or restarts.
setPkCacheSize
in class JdbcPkGenerator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |