Klasse AbstractIdGenerator

java.lang.Object
org.apache.torque.oid.AbstractIdGenerator
Alle implementierten Schnittstellen:
IdGenerator
Bekannte direkte Unterklassen:
AutoIncrementIdGenerator, SequenceIdGenerator

public abstract class AbstractIdGenerator extends Object implements IdGenerator
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
  • Felddetails

    • adapter

      protected Adapter adapter
      The adapter that knows the correct sql syntax
    • databaseName

      protected String databaseName
      The internal name of the Database that this Generator is connected to.
  • Konstruktordetails

    • AbstractIdGenerator

      public AbstractIdGenerator(Adapter adapter, String databaseName)
      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

      public int getIdAsInt(Connection connection, Object keyInfo) throws TorqueException
      Returns the last ID used by this connection.
      Angegeben von:
      getIdAsInt in Schnittstelle IdGenerator
      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

      public long getIdAsLong(Connection connection, Object keyInfo) throws TorqueException
      Returns the last ID used by this connection.
      Angegeben von:
      getIdAsLong in Schnittstelle IdGenerator
      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

      public BigDecimal getIdAsBigDecimal(Connection connection, Object keyInfo) throws TorqueException
      Returns the last ID used by this connection.
      Angegeben von:
      getIdAsBigDecimal in Schnittstelle IdGenerator
      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

      public String getIdAsString(Connection connection, Object keyInfo) throws TorqueException
      Returns the last ID used by this connection.
      Angegeben von:
      getIdAsString in Schnittstelle IdGenerator
      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 Schnittstelle IdGenerator
      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 Schnittstelle IdGenerator
      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 Schnittstelle IdGenerator
      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 Schnittstelle IdGenerator
      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

      public String getIdSql(Object keyInfo) throws TorqueException
      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.