org.castor.cpa.persistence.sql.keygen
Class SequenceKeyGenerator
java.lang.Object
org.castor.cpa.persistence.sql.keygen.AbstractKeyGenerator
org.castor.cpa.persistence.sql.keygen.SequenceKeyGenerator
- All Implemented Interfaces:
- KeyGenerator
public final class SequenceKeyGenerator
- extends AbstractKeyGenerator
SEQUENCE key generator.
- Version:
- $Revision: 7715 $ $Date: 2006-04-13 06:47:36 -0600 (Thu, 13 Apr 2006) $
- Author:
- Oleg Nitz, Bruce Snyder
- See Also:
SequenceKeyGeneratorFactory
|
Method Summary |
java.lang.Object |
generateKey(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String primKeyName,
java.util.Properties props)
Generate a new key for the specified table. |
java.lang.String[] |
getSupportedFactoryNames()
|
java.lang.String |
patchSQL(java.lang.String insert,
java.lang.String primKeyName)
Gives a possibility to patch the Castor-generated SQL statement
for INSERT (makes sense for DURING_INSERT key generators). |
void |
supportsSqlType(int sqlType)
Determine if the key generator supports a given sql type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SequenceKeyGenerator
public SequenceKeyGenerator(PersistenceFactory factory,
java.util.Properties params,
int sqlType)
throws MappingException
- Initialize the SEQUENCE key generator.
- Throws:
MappingException
supportsSqlType
public void supportsSqlType(int sqlType)
throws MappingException
- Determine if the key generator supports a given sql type.
- Specified by:
supportsSqlType in interface KeyGenerator- Overrides:
supportsSqlType in class AbstractKeyGenerator
- Parameters:
sqlType -
- Throws:
MappingException
getSupportedFactoryNames
public java.lang.String[] getSupportedFactoryNames()
- Specified by:
getSupportedFactoryNames in class AbstractKeyGenerator
generateKey
public java.lang.Object generateKey(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String primKeyName,
java.util.Properties props)
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:
conn - An open connection within the given transaction.tableName - The table name.primKeyName - The primary key name.props - A temporary replacement for Principal object.
- Returns:
- A new key.
- Throws:
PersistenceException - An error occured talking to persistent storage.
patchSQL
public java.lang.String patchSQL(java.lang.String insert,
java.lang.String primKeyName)
throws MappingException
- Gives a possibility to patch the Castor-generated SQL statement
for INSERT (makes sense for DURING_INSERT key generators).
- Specified by:
patchSQL in interface KeyGenerator- Overrides:
patchSQL in class AbstractKeyGenerator
- Parameters:
insert - Castor-generated INSERT statementprimKeyName - The primary key name
- Throws:
MappingException
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com