public abstract class AbstractIdGenerator extends Object implements IdGenerator
| Modifier and Type | Field and Description |
|---|---|
protected Adapter |
adapter
The adapter that knows the correct sql syntax
|
protected String |
databaseName
The internal name of the Database that this Generator is connected to.
|
| Constructor and Description |
|---|
AbstractIdGenerator(Adapter adapter,
String databaseName)
Creates an IdGenerator which will work with the specified database.
|
| Modifier and Type | Method and Description |
|---|---|
protected <T> T |
getId(Connection connection,
Object keyInfo,
RecordMapper<T> mapper)
Returns the last ID used by this connection.
|
BigDecimal |
getIdAsBigDecimal(Connection connection,
Object keyInfo)
Returns the last ID used by this connection.
|
int |
getIdAsInt(Connection connection,
Object keyInfo)
Returns the last ID used by this connection.
|
long |
getIdAsLong(Connection connection,
Object keyInfo)
Returns the last ID used by this connection.
|
String |
getIdAsString(Connection connection,
Object keyInfo)
Returns the last ID used by this connection.
|
String |
getIdSql(Object keyInfo)
Returns the SQL to retrieve the next id.
|
abstract boolean |
isConnectionRequired()
A flag to determine whether a Connection is required to
generate an id.
|
abstract boolean |
isGetGeneratedKeysSupported()
A flag to determine whether Statement#getGeneratedKeys()
should be used.
|
abstract boolean |
isPostInsert()
A flag to determine the timing of the id generation
|
abstract boolean |
isPriorToInsert()
A flag to determine the timing of the id generation
|
protected Adapter adapter
protected String databaseName
public int getIdAsInt(Connection connection, Object keyInfo) throws TorqueException
getIdAsInt in interface IdGeneratorconnection - The database connection to read the new id, not null.keyInfo - the name of the table for which the id is retrieved.TorqueException - if a database error occurs.public long getIdAsLong(Connection connection, Object keyInfo) throws TorqueException
getIdAsLong in interface IdGeneratorconnection - The database connection to read the new id, not null.keyInfo - the name of the table for which the id is retrieved.TorqueException - if a database error occurs.public BigDecimal getIdAsBigDecimal(Connection connection, Object keyInfo) throws TorqueException
getIdAsBigDecimal in interface IdGeneratorconnection - The database connection to read the new id, not null.keyInfo - the name of the table for which the id is retrieved.TorqueException - if a database error occurs.public String getIdAsString(Connection connection, Object keyInfo) throws TorqueException
getIdAsString in interface IdGeneratorconnection - The database connection to read the new id, not null.keyInfo - the name of the table for which the id is retrieved.TorqueException - if a database error occurs.public abstract boolean isPriorToInsert()
isPriorToInsert in interface IdGeneratorboolean valuepublic abstract boolean isPostInsert()
isPostInsert in interface IdGeneratorboolean valuepublic abstract boolean isConnectionRequired()
isConnectionRequired in interface IdGeneratorboolean valuepublic abstract boolean isGetGeneratedKeysSupported()
isGetGeneratedKeysSupported in interface IdGeneratorboolean valueprotected <T> T getId(Connection connection, Object keyInfo, RecordMapper<T> mapper) throws TorqueException
T - the id object classconnection - A Connection.keyInfo - an Object that contains additional info.mapper - The RecordMapper that maps from a ResultSet to the
appropriate java object.TorqueException - if a database error occurs.public String getIdSql(Object keyInfo) throws TorqueException
keyInfo - an Object that contains additional info.TorqueException - if a database error occurs.Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.