Class TableKeyGenerator
java.lang.Object
org.castor.cpa.persistence.sql.keygen.AbstractKeyGenerator
org.castor.cpa.persistence.sql.keygen.AbstractBeforeKeyGenerator
org.castor.cpa.persistence.sql.keygen.TableKeyGenerator
- All Implemented Interfaces:
KeyGenerator
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTableKeyGenerator
(PersistenceFactory factory, Properties params, int sqlType) Creates an instance of this key generator. -
Method Summary
Modifier and TypeMethodDescriptiongenerateKey
(Connection connection, String tableName, String primKeyName) Generate a new key for the specified table.boolean
Is key generated in the same connection as INSERT? For DURING_INSERT style this method is never called.Methods inherited from class org.castor.cpa.persistence.sql.keygen.AbstractBeforeKeyGenerator
bindIdentity, buildStatement, executeStatement
Methods inherited from class org.castor.cpa.persistence.sql.keygen.AbstractKeyGenerator
closeSeparateConnection, getSeparateConnection
-
Field Details
-
DESCRIPTOR_KEY
- See Also:
-
DEFAULT_TABLE_NAME
- See Also:
-
DEFAULT_ALLOCATION_SIZE
public static final int DEFAULT_ALLOCATION_SIZE- See Also:
-
DEFAULT_INITIAL_VALUE
public static final int DEFAULT_INITIAL_VALUE- See Also:
-
DEFAULT_PK_COLUMN_NAME
- See Also:
-
DEFAULT_VALUE_COLUMN_NAME
- See Also:
-
DEFAULT_PK_COLUMN_VALUE
- See Also:
-
-
Constructor Details
-
TableKeyGenerator
public TableKeyGenerator(PersistenceFactory factory, Properties params, int sqlType) throws MappingException Creates an instance of this key generator.- Parameters:
factory
- The currentPersistenceFactory
instance.params
- Parameters for the key generator.sqlType
- The SQL type of the identity field.- Throws:
MappingException
-
-
Method Details
-
generateKey
public Object generateKey(Connection connection, String tableName, String primKeyName) throws PersistenceException Description copied from interface:KeyGenerator
Generate a new key for the specified table. This method is called when a new object is about to be created. In some environments the name of the owner of the object is known, e.g. the principal in a J2EE server. This method is never called for DURING_INSERT key generators.- Parameters:
connection
- An open connection within the given transactiontableName
- The table nameprimKeyName
- The primary key name- Returns:
- A new key
- Throws:
PersistenceException
- An error occured talking to persistent storage
-
isInSameConnection
public boolean isInSameConnection()Description copied from interface:KeyGenerator
Is key generated in the same connection as INSERT? For DURING_INSERT style this method is never called.- Returns:
- {code}True{code} If this instance is in same JDBC Connection.
-
getFactory
-
getDescriptor
-