Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.objectstyle.cayenne.dba.openbase
Class OpenBasePkGenerator

    java.lang.Object
      org.objectstyle.cayenne.dba.JdbcPkGenerator
          org.objectstyle.cayenne.dba.openbase.OpenBasePkGenerator

All Implemented Interfaces:
  PkGenerator

    public class OpenBasePkGenerator

extends JdbcPkGenerator

Since:
  1.1
Author:
  Mike Kienenberger, Andrei Adamchik

Field Summary

Fields inherited from class org.objectstyle.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.objectstyle.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

### OpenBasePkGenerator

    public OpenBasePkGenerator()

Method Detail

### generatePkForDbEntityString

    public java.lang.String generatePkForDbEntityString(DbEntity ent)

  Deprecated. Since 1.2 corresponding interface method is unused and deprecated.

  Description copied from interface: `PkGenerator`
  Returns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity. No actual database operations are performed.

  Specified by:
    `generatePkForDbEntityString` in interface `PkGenerator`
  Overrides:
    `generatePkForDbEntityString` in class `JdbcPkGenerator`

### generatePkForDbEntity

    public java.lang.Object generatePkForDbEntity(DataNode node,
                                                  DbEntity entity)
                                           throws java.lang.Exception

  Returns a non-repeating primary key for a given entity. Since OpenBase-specific mechanism is used, key caching is disabled. Instead a database operation is performed on every call.

  Specified by:
    `generatePkForDbEntity` in interface `PkGenerator`
  Overrides:
    `generatePkForDbEntity` in class `JdbcPkGenerator`
    `entity` - DbEntity for which automatic PK is generated.
  Throws:
    `java.lang.Exception`

### pkFromDatabase

    protected int pkFromDatabase(DataNode node,
                                 DbEntity entity)
                          throws java.lang.Exception

  Generates new (unique and non-repeating) primary key for specified DbEntity. Executed SQL looks like this:

       NEWID FOR Table Column

  COLUMN must be marked as UNIQUE in order for this to work properly.

  Overrides:
    `pkFromDatabase` in class `JdbcPkGenerator`
  Throws:
    `java.lang.Exception`

### newIDString

    protected java.lang.String newIDString(DbEntity ent)

  Returns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity. No actual database operations are performed.

  Since:
    1.2

### createAutoPk

    public void createAutoPk(DataNode node,
                             java.util.List dbEntities)
                      throws java.lang.Exception

  Description copied from interface: `PkGenerator`
  Generates necessary database objects to provide automatic primary key support.

  Specified by:
    `createAutoPk` in interface `PkGenerator`
  Overrides:
    `createAutoPk` in class `JdbcPkGenerator`
  Parameters:
    `node` - node that provides access to a DataSource.
    `dbEntities` - a list of entities that require primary key autogeneration support
  Throws:
    `java.lang.Exception`

### createAutoPkStatements

    public java.util.List createAutoPkStatements(java.util.List dbEntities)

  Description copied from interface: `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.

  Specified by:
    `createAutoPkStatements` in interface `PkGenerator`
  Overrides:
    `createAutoPkStatements` in class `JdbcPkGenerator`

### canCreatePK

    protected boolean canCreatePK(DbEntity entity)

### dropAutoPk

    public void dropAutoPk(DataNode node,
                           java.util.List dbEntities)
                    throws java.lang.Exception

  Description copied from class: `JdbcPkGenerator`
  Drops table named "AUTO_PK_SUPPORT" if it exists in the database.

  Specified by:
    `dropAutoPk` in interface `PkGenerator`
  Overrides:
    `dropAutoPk` in class `JdbcPkGenerator`
  Parameters:
    `node` - node that provides access to a DataSource.
    `dbEntities` - a list of entities whose primary key autogeneration support should be dropped.
  Throws:
    `java.lang.Exception`

### dropAutoPkStatements

    public java.util.List dropAutoPkStatements(java.util.List dbEntities)

  Returns an empty list, since OpenBase doesn't support this operation.

  Specified by:
    `dropAutoPkStatements` in interface `PkGenerator`
  Overrides:
    `dropAutoPkStatements` in class `JdbcPkGenerator`

### createPKString

    protected java.lang.String createPKString(DbEntity entity)

  Returns a String to create PK support for an entity.

### createUniquePKIndexString

    protected java.lang.String createUniquePKIndexString(DbEntity entity)

  Returns a String to create a unique index on table primary key columns per OpenBase recommendations.

### reset

    public void reset()

  Description copied from interface: `PkGenerator`
  Resets any cached primary keys forcing generator to go to the database next time id generation is requested. May not be applicable for all generator implementations.

  Specified by:
    `reset` in interface `PkGenerator`
  Overrides:
    `reset` in class `JdbcPkGenerator`

### getPkCacheSize

    public int getPkCacheSize()

  Returns zero, since PK caching is not feasible with OpenBase PK generation mechanism.

  Overrides:
    `getPkCacheSize` in class `JdbcPkGenerator`

### setPkCacheSize

    public void setPkCacheSize(int pkCacheSize)

  Description copied from class: `JdbcPkGenerator`
  Sets the size of the entity primary key cache. If `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.

  Overrides:
    `setPkCacheSize` in class `JdbcPkGenerator`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.