Class FirebirdDictionary

java.lang.Object
org.apache.openjpa.jdbc.sql.DBDictionary
org.apache.openjpa.jdbc.sql.FirebirdDictionary
All Implemented Interfaces:
JoinSyntaxes, Configurable, IdentifierConfiguration, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler

public class FirebirdDictionary extends DBDictionary
Dictionary for Firebird. Supports Firebird versions 1.5, 2.0 and 2.1.
  • Field Details

    • firebirdVersion

      public int firebirdVersion
    • indexedVarcharMaxSizeFB15

      public int indexedVarcharMaxSizeFB15
    • rangeSyntax

      public String rangeSyntax
    • maxRowNumberInRange

      protected long maxRowNumberInRange
    • alterSequenceSQLFB15

      protected String alterSequenceSQLFB15
    • alterSequenceSQLFB20

      protected String alterSequenceSQLFB20
    • createSequenceSQLFB15

      protected String createSequenceSQLFB15
    • createSequenceSQLFB20

      protected String createSequenceSQLFB20
    • dropSequenceSQLFB15

      protected String dropSequenceSQLFB15
    • alterSequenceSQL

      protected String alterSequenceSQL
    • createSequenceSQL

      protected String createSequenceSQL
    • FB_VERSION_15

      public static final int FB_VERSION_15
      See Also:
    • FB_VERSION_20

      public static final int FB_VERSION_20
      See Also:
    • FB_VERSION_21

      public static final int FB_VERSION_21
      See Also:
    • RANGE_SYNTAX_FIRST_SKIP

      public static final String RANGE_SYNTAX_FIRST_SKIP
      See Also:
    • RANGE_SYNTAX_ROWS

      public static final String RANGE_SYNTAX_ROWS
      See Also:
  • Constructor Details

    • FirebirdDictionary

      public FirebirdDictionary()
  • Method Details

    • connectedConfiguration

      public void connectedConfiguration(Connection conn) throws SQLException
      Determine Firebird version and configure itself accordingly.
      Overrides:
      connectedConfiguration in class DBDictionary
      Throws:
      SQLException
    • appendSelectRange

      protected void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)
      Use either FIRST <p> SKIP <q> or ROWS <m> TO <n> syntax. If ROWS variant is used and end equals Long.MAX_VALUE, a constant is used as <n> value.
      Overrides:
      appendSelectRange in class DBDictionary
    • determineFirebirdVersion

      protected int determineFirebirdVersion(Connection con) throws SQLException
      Determine Firebird version either by using JDBC 3 methods or, if they are not available, by parsing the value returned by DatabaseMetaData.getDatabaseProductVersion(). User can override Firebird version.
      Throws:
      SQLException
    • determineRangeSyntax

      protected void determineRangeSyntax()
      Determine range syntax to be used depending on Firebird version. User can override range syntax.
    • getPlaceholderValueString

      public String getPlaceholderValueString(Column col)
      Return <value> AS <type>.
      Overrides:
      getPlaceholderValueString in class DBDictionary
    • getTableNameForMetadata

      protected String getTableNameForMetadata(String tableName)
      Return % if tableName is null, otherwise delegate to super implementation.
      Overrides:
      getTableNameForMetadata in class DBDictionary
    • getTableNameForMetadata

      protected String getTableNameForMetadata(DBIdentifier tableName)
      Description copied from class: DBDictionary
      Returns the table name that will be used for obtaining information from DatabaseMetaData.
      Overrides:
      getTableNameForMetadata in class DBDictionary
    • getColumnNameForMetadata

      protected String getColumnNameForMetadata(String columnName)
      Return % if columnName is null, otherwise delegate to super implementation.
      Overrides:
      getColumnNameForMetadata in class DBDictionary
    • getDropColumnSQL

      public String[] getDropColumnSQL(Column column)
      Return ALTER TABLE <table name> DROP <col name>.
      Overrides:
      getDropColumnSQL in class DBDictionary
    • getCreateSequenceSQL

      public String[] getCreateSequenceSQL(Sequence seq)
      Return either CREATE SEQUENCE <sequence name> or CREATE GENERATOR <sequence name>. If initial value of sequence is set, return also an appropriate ALTER statement.
      Overrides:
      getCreateSequenceSQL in class DBDictionary
    • getSequencesSQL

      protected String getSequencesSQL(String schemaName, String sequenceName)
      Return Firebird-specific statement to select the list of sequences.
      Overrides:
      getSequencesSQL in class DBDictionary
    • getSequencesSQL

      protected String getSequencesSQL(DBIdentifier schemaName, DBIdentifier sequenceName)
      Overrides:
      getSequencesSQL in class DBDictionary
    • newSequence

      protected Sequence newSequence(ResultSet sequenceMeta) throws SQLException
      Call super implementation and trim sequence name. This is because of trailing spaces problem: RDB$GENERATORS.RDB$GENERATOR_NAME is CHAR(31) and using RTRIM UDF function on Firebird 1.5 surprisingly returns a string right-padded with spaces up to the length of 255.
      Overrides:
      newSequence in class DBDictionary
      Throws:
      SQLException
    • getDropSequenceSQL

      public String[] getDropSequenceSQL(Sequence seq)
      On Firebird 1.5 return DROP GENERATOR <sequence name>. On Firebird 2.0 and later delegate to the super implementation.
      Overrides:
      getDropSequenceSQL in class DBDictionary
    • indexOf

      public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find, FilterValue start)
      On Firebird 2.1 return POSITION(<find>, <str> [, <start>]). On older versions throw UnsupportedException - no suitable function exists.
      Overrides:
      indexOf in class DBDictionary
      Parameters:
      buf - the SQL buffer to write the indexOf invocation to
      str - a query value representing the target string
      find - a query value representing the search string
      start - a query value representing the start index, or null to start at the beginning
    • substring

      public void substring(SQLBuffer buf, FilterValue str, FilterValue start, FilterValue length)
      Use SUBSTRING(<col name> FROM <m> FOR <n>). Parameters are inlined because neither parameter binding nor expressions are accepted by Firebird here. As a result, an UnsupportedException is thrown when something else than a constant is used in start or length.
      Overrides:
      substring in class DBDictionary
      Parameters:
      buf - the SQL buffer to write the substring invocation to
      str - a query value representing the target string
      start - a query value representing the start index
      length - a query value representing the length of substring, or null for none
    • appendSize

      protected String appendSize(Column col, String typeName)
      On Firebird 1.5 reduce the size of indexed VARCHAR column to 252 or a value specified by user. 252 is the maximum Firebird 1.5 can handle for one-column indexes. On Firebird 2.0 and later delegate to the super implementation.
      Overrides:
      appendSize in class DBDictionary
    • matchErrorState

      protected int matchErrorState(Map<Integer,Set<String>> errorStates, SQLException ex)
      Use error code as SQL state returned by Firebird is ambiguous.
      Overrides:
      matchErrorState in class DBDictionary
      Parameters:
      errorStates - classification of SQL error states by their specific nature. The keys of the map represent one of the constants defined in StoreException. The value corresponding to a key represent the set of SQL Error States representing specific category of database error. This supplied map is sourced from sql-error-state-codes.xml and filtered the error states for the current database.
      ex - original SQL Exception as raised by the database driver.
      Returns:
      A constant indicating the category of error as defined in StoreException.