Class SybaseDictionary

  • All Implemented Interfaces:
    JoinSyntaxes, Configurable, IdentifierConfiguration, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler

    public class SybaseDictionary
    extends AbstractSQLServerDictionary
    Dictionary for Sybase. The main point of interest is that by default, every table that is created will have a unique column named "UNQ_INDEX" of the "IDENTITY" type. OpenJPA will not ever utilize this column. However, due to internal Sybase restrictions, this column is required in order to support pessimistic (datastore) locking, since Sybase requires that any tables in a "SELECT ... FOR UPDATE" clause have a unique index that is not included in the list of columns, as described in the Sybase documentation. This behavior can be surpressed by setting the dictionary property CreateIdentityColumn=false. The name of the unique column can be changed by setting the property IdentityColumnName=COLUMN_NAME. A good Sybase type reference is can be found here.
    • Field Detail

      • RIGHT_TRUNCATION_ON_SQL

        public static java.lang.String RIGHT_TRUNCATION_ON_SQL
      • NUMERIC_TRUNCATION_OFF_SQL

        public static java.lang.String NUMERIC_TRUNCATION_OFF_SQL
      • createIdentityColumn

        public boolean createIdentityColumn
        If true, then whenever the schematool creates a table, it will append an additional IDENTITY column to the table's creation SQL. This is so Sybase will be able to perform SELECT...FOR UPDATE statements.
      • identityColumnName

        public java.lang.String identityColumnName
        If createIdentityColumn is true, then the identityColumnName will be the name of the additional unique column that will be created.
      • ignoreNumericTruncation

        public boolean ignoreNumericTruncation
        If true, Sybase will ignore numeric truncation on insert or update operations. Otherwise, the operation will fail. The default value, false is in accordance with SQL92.
    • Constructor Detail

      • SybaseDictionary

        public SybaseDictionary()
    • Method Detail

      • setBigInteger

        public void setBigInteger​(java.sql.PreparedStatement stmnt,
                                  int idx,
                                  java.math.BigInteger val,
                                  Column col)
                           throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set the given value as a parameter to the statement.
        Overrides:
        setBigInteger in class DBDictionary
        Throws:
        java.sql.SQLException
      • getCreateTableSQL

        public java.lang.String[] getCreateTableSQL​(Table table)
        Description copied from class: DBDictionary
        Return a series of SQL statements to create the given table, complete with columns. Indexes and constraints will be created separately.
        Overrides:
        getCreateTableSQL in class DBDictionary
      • getDropColumnSQL

        public java.lang.String[] getDropColumnSQL​(Column column)
        Description copied from class: DBDictionary
        Return a series of SQL statements to drop the given column from its table. Return an empty array if operation not supported. Returns ALTER TABLE <table name> DROP COLUMN <col name> by default.
        Overrides:
        getDropColumnSQL in class DBDictionary
      • refSchemaComponents

        public void refSchemaComponents​(Table table)
        Description copied from class: DBDictionary
        Increment the reference count of any table components that this dictionary adds that are not used by mappings. Does nothing by default.
        Overrides:
        refSchemaComponents in class DBDictionary
      • decorate

        public java.sql.Connection decorate​(java.sql.Connection conn)
                                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Decorate the given connection if needed. Some databases require special handling for JDBC bugs. This implementation issues any DBDictionary.initializationSQL that has been set for the dictionary but does not decorate the connection.
        Specified by:
        decorate in interface ConnectionDecorator
        Overrides:
        decorate in class DBDictionary
        Throws:
        java.sql.SQLException
      • getStringFromResultSet

        protected java.lang.String getStringFromResultSet​(java.sql.ResultSet rs,
                                                          java.lang.String jdbcName,
                                                          java.lang.String sybaseName)
                                                   throws java.sql.SQLException
        Helper method obtains a string value from a given column in a ResultSet. Strings provided are column names, jdbcName will be tried first if an SQLException occurs we'll try the sybase name.
        Throws:
        java.sql.SQLException
      • getBooleanFromResultSet

        protected boolean getBooleanFromResultSet​(java.sql.ResultSet rs,
                                                  java.lang.String jdbcName,
                                                  java.lang.String sybaseName)
                                           throws java.sql.SQLException
        Helper method obtains a boolean value from a given column in a ResultSet. Strings provided are column names, jdbcName will be tried first if an SQLException occurs we'll try the sybase name.
        Throws:
        java.sql.SQLException
      • newPrimaryKey

        protected PrimaryKey newPrimaryKey​(java.sql.ResultSet pkMeta)
                                    throws java.sql.SQLException
        Create a new primary key from the information in the schema metadata.
        Overrides:
        newPrimaryKey in class DBDictionary
        Throws:
        java.sql.SQLException
      • newIndex

        protected Index newIndex​(java.sql.ResultSet idxMeta)
                          throws java.sql.SQLException
        Create a new index from the information in the index metadata.
        Overrides:
        newIndex in class DBDictionary
        Throws:
        java.sql.SQLException
      • isFatalException

        public boolean isFatalException​(int subtype,
                                        java.sql.SQLException ex)
        Description copied from class: DBDictionary
        Determine if the given SQL Exception is fatal or recoverable (such as a timeout). This implementation always returns true (i.e. all exceptions are fatal). The current dictionary implementation can overwrite this method to mark certain exception conditions as recoverable error.
        Overrides:
        isFatalException in class DBDictionary
        Parameters:
        subtype - A constant indicating the category of error as defined in StoreException.
        ex - original SQL Exception as raised by the database driver.
        Returns:
        false if the error is fatal.
      • getIsNullSQL

        public java.lang.String getIsNullSQL​(java.lang.String colAlias,
                                             int colType)
        Overrides:
        getIsNullSQL in class DBDictionary
      • getIsNotNullSQL

        public java.lang.String getIsNotNullSQL​(java.lang.String colAlias,
                                                int colType)
        Overrides:
        getIsNotNullSQL in class DBDictionary
      • indexOf

        public void indexOf​(SQLBuffer buf,
                            FilterValue str,
                            FilterValue find,
                            FilterValue start)
        Description copied from class: DBDictionary
        Invoke this database's indexOf function.
        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