Package org.apache.torque.oid
Klasse AbstractIdGenerator
java.lang.Object
org.apache.torque.oid.AbstractIdGenerator
- Alle implementierten Schnittstellen:
IdGenerator
- Bekannte direkte Unterklassen:
AutoIncrementIdGenerator
,SequenceIdGenerator
This class serves as a common base class for the sequence-based and the
autoincrement-based id generators
- Version:
- $Id: AbstractIdGenerator.java 1850965 2019-01-10 17:21:29Z painter $
- Autor:
- Thomas Vandahl
-
Feldübersicht
Felder -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungAbstractIdGenerator
(Adapter adapter, String databaseName) Creates an IdGenerator which will work with the specified database. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected <T> T
getId
(Connection connection, Object keyInfo, RecordMapper<T> mapper) Returns the last ID used by this connection.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.getIdAsString
(Connection connection, Object keyInfo) Returns the last ID used by this connection.Returns the SQL to retrieve the next id.abstract boolean
A flag to determine whether a Connection is required to generate an id.abstract boolean
A flag to determine whether Statement#getGeneratedKeys() should be used.abstract boolean
A flag to determine the timing of the id generationabstract boolean
A flag to determine the timing of the id generation
-
Felddetails
-
adapter
The adapter that knows the correct sql syntax -
databaseName
The internal name of the Database that this Generator is connected to.
-
-
Konstruktordetails
-
AbstractIdGenerator
Creates an IdGenerator which will work with the specified database.- Parameter:
adapter
- the adapter that knows the correct sql syntax.databaseName
- The name of the databaseName to find the correct schema.
-
-
Methodendetails
-
getIdAsInt
Returns the last ID used by this connection.- Angegeben von:
getIdAsInt
in SchnittstelleIdGenerator
- Parameter:
connection
- The database connection to read the new id, not null.keyInfo
- the name of the table for which the id is retrieved.- Gibt zurück:
- An int with the new id.
- Löst aus:
TorqueException
- if a database error occurs.
-
getIdAsLong
Returns the last ID used by this connection.- Angegeben von:
getIdAsLong
in SchnittstelleIdGenerator
- Parameter:
connection
- The database connection to read the new id, not null.keyInfo
- the name of the table for which the id is retrieved.- Gibt zurück:
- A long with the new id.
- Löst aus:
TorqueException
- if a database error occurs.
-
getIdAsBigDecimal
Returns the last ID used by this connection.- Angegeben von:
getIdAsBigDecimal
in SchnittstelleIdGenerator
- Parameter:
connection
- The database connection to read the new id, not null.keyInfo
- the name of the table for which the id is retrieved.- Gibt zurück:
- A BigDecimal with the new id.
- Löst aus:
TorqueException
- if a database error occurs.
-
getIdAsString
Returns the last ID used by this connection.- Angegeben von:
getIdAsString
in SchnittstelleIdGenerator
- Parameter:
connection
- The database connection to read the new id, not null.keyInfo
- the name of the table for which the id is retrieved.- Gibt zurück:
- A String with the new id.
- Löst aus:
TorqueException
- if a database error occurs.
-
isPriorToInsert
public abstract boolean isPriorToInsert()A flag to determine the timing of the id generation- Angegeben von:
isPriorToInsert
in SchnittstelleIdGenerator
- Gibt zurück:
- a
boolean
value
-
isPostInsert
public abstract boolean isPostInsert()A flag to determine the timing of the id generation- Angegeben von:
isPostInsert
in SchnittstelleIdGenerator
- Gibt zurück:
- a
boolean
value
-
isConnectionRequired
public abstract boolean isConnectionRequired()A flag to determine whether a Connection is required to generate an id.- Angegeben von:
isConnectionRequired
in SchnittstelleIdGenerator
- Gibt zurück:
- a
boolean
value
-
isGetGeneratedKeysSupported
public abstract boolean isGetGeneratedKeysSupported()A flag to determine whether Statement#getGeneratedKeys() should be used.- Angegeben von:
isGetGeneratedKeysSupported
in SchnittstelleIdGenerator
- Gibt zurück:
- a
boolean
value
-
getId
protected <T> T getId(Connection connection, Object keyInfo, RecordMapper<T> mapper) throws TorqueException Returns the last ID used by this connection.- Typparameter:
T
- the id object class- Parameter:
connection
- A Connection.keyInfo
- an Object that contains additional info.mapper
- The RecordMapper that maps from a ResultSet to the appropriate java object.- Gibt zurück:
- The generated id.
- Löst aus:
TorqueException
- if a database error occurs.
-
getIdSql
Returns the SQL to retrieve the next id.- Parameter:
keyInfo
- an Object that contains additional info.- Gibt zurück:
- the SQL to retrieve the next id.
- Löst aus:
TorqueException
- if a database error occurs.
-