public interface KeyGenerator
All the key generators belonging to the same database share the same non-transactional connection to the database.
The key generator is configured from the mapping file using Bean-like accessor methods.
| Modifier and Type | Field and Description |
|---|---|
static byte |
AFTER_INSERT
For the key generators of AFTER_INSERT style
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is called after INSERT. |
static byte |
BEFORE_INSERT
For the key generators of BEFORE_INSERT style
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is called before INSERT. |
static byte |
DURING_INSERT
For the key generators of DURING_INSERT style
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is never called, all work is done by patchSQL(java.lang.String, java.lang.String). |
| Modifier and Type | Method and Description |
|---|---|
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.
|
byte |
getStyle()
Style of the key generator: BEFORE_INSERT, DURING_INSERT or AFTER_INSERT.
|
boolean |
isInSameConnection()
Is key generated in the same connection as INSERT?
For DURING_INSERT style this method is never called.
|
java.lang.String |
patchSQL(java.lang.String insert,
java.lang.String primKeyName)
Gives a possibility to patch the Castor-generated SQL statement
for INSERT (indended mainly for DURING_INSERT style of key generators,
other key generators usually simply return the passed parameter).
|
void |
supportsSqlType(int sqlType)
Determine if the key generator supports a given sql type.
|
static final byte BEFORE_INSERT
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is called before INSERT.
patchSQL(java.lang.String, java.lang.String) may be used but usually doesn't.static final byte DURING_INSERT
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is never called, all work is done by patchSQL(java.lang.String, java.lang.String).static final byte AFTER_INSERT
generateKey(java.sql.Connection, java.lang.String, java.lang.String, java.util.Properties)
is called after INSERT.
patchSQL(java.lang.String, java.lang.String) may be used but usually doesn't.java.lang.Object generateKey(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String primKeyName,
java.util.Properties props)
throws PersistenceException
conn - An open connection within the given transactiontableName - The table nameprimKeyName - The primary key nameprops - A temporary replacement for Principal objectPersistenceException - An error occured talking to persistent
storagevoid supportsSqlType(int sqlType)
throws MappingException
sqlType - MappingExceptionbyte getStyle()
java.lang.String patchSQL(java.lang.String insert,
java.lang.String primKeyName)
throws MappingException
insert - Castor-generated INSERT statementprimKeyName - The primary key nameMappingExceptionboolean isInSameConnection()
Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com