|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface KeyGenerator
Interface for a key generator. The key generator is used for producing identities for objects before they are created in the database.
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.
Field Summary | |
---|---|
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) . |
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. |
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. |
Field Detail |
---|
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.
Method Detail |
---|
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 object
PersistenceException
- An error occured talking to persistent
storagevoid supportsSqlType(int sqlType) throws MappingException
sqlType
-
MappingException
byte getStyle()
java.lang.String patchSQL(java.lang.String insert, java.lang.String primKeyName) throws MappingException
insert
- Castor-generated INSERT statementprimKeyName
- The primary key name
MappingException
boolean isInSameConnection()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |