Class OracleDictionary

    • Field Detail

      • useTriggersForAutoAssign

        @Deprecated
        public boolean useTriggersForAutoAssign
        Deprecated.
        If true, then simulate auto-assigned values in Oracle by using a trigger that inserts a sequence value into the primary key value when a row is inserted.
      • autoAssignSequenceName

        @Deprecated
        public java.lang.String autoAssignSequenceName
        Deprecated.
        The global sequence name to use for autoassign simulation.
      • nativeJavaTimeSupport

        public boolean nativeJavaTimeSupport
        Whether this JDBC driver has native java.time support for LocalDate, LocalDateTime, LocalTime, OffsetTime and OffsetDateTime
      • openjpa3GeneratedKeyNames

        public boolean openjpa3GeneratedKeyNames
        Flag to use OpenJPA 0.3 style naming for auto assign sequence name and trigger name for backwards compatibility.
      • useSetFormOfUseForUnicode

        public boolean useSetFormOfUseForUnicode
        If true, then OpenJPA will attempt to use the special OraclePreparedStatement.setFormOfUse method to configure statements that it detects are operating on unicode fields.
      • supportsSetClob

        @Deprecated
        public boolean supportsSetClob
        Deprecated.
        This variable was used prior to 2.1.x to indicate that OpenJPA should attempt to use a Reader-based JDBC 4.0 method to set Clob or XML data. It allowed XMLType and Clob values larger than 4000 bytes to be used. For 2.1.x+, code was added to allow said functionality by default (see OPENJPA-1691). For forward compatibility, this variable should not be removed.
      • xmlTypeMarker

        public java.lang.String xmlTypeMarker
        Type constructor for XML column, used in INSERT and UPDATE statements.
    • Constructor Detail

      • OracleDictionary

        public OracleDictionary()
    • Method Detail

      • connectedConfiguration

        public void connectedConfiguration​(java.sql.Connection conn)
                                    throws java.sql.SQLException
        Description copied from class: DBDictionary
        This method is called when the dictionary first sees any connection. It is used to initialize dictionary metadata if needed. If you override this method, be sure to call super.connectedConfiguration.
        Overrides:
        connectedConfiguration in class DBDictionary
        Throws:
        java.sql.SQLException
      • ensureDriverVendor

        public void ensureDriverVendor()
        Ensure that the driver vendor has been set, and if not, set it now.
      • supportsLocking

        public boolean supportsLocking​(Select sel)
        Description copied from class: DBDictionary
        Returns true if a "FOR UPDATE" clause can be used for the specified Select object.
        Overrides:
        supportsLocking in class DBDictionary
      • getSelects

        protected SQLBuffer getSelects​(Select sel,
                                       boolean distinctIdentifiers,
                                       boolean forUpdate)
        Description copied from class: DBDictionary
        Return the portion of the select statement between the SELECT keyword and the FROM keyword.
        Overrides:
        getSelects in class DBDictionary
      • canOuterJoin

        public boolean canOuterJoin​(int syntax,
                                    ForeignKey fk)
        Description copied from class: DBDictionary
        Returns if the given foreign key can be eagerly loaded using other joins.
        Overrides:
        canOuterJoin in class DBDictionary
      • toNativeJoin

        public SQLBuffer toNativeJoin​(Join join)
        Description copied from class: DBDictionary
        Use the given join instance to create SQL joining its tables in the database's native syntax. Throws an exception by default.
        Overrides:
        toNativeJoin in class DBDictionary
      • setString

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

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

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

        public void setNull​(java.sql.PreparedStatement stmnt,
                            int idx,
                            int colType,
                            Column col)
                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set null as a parameter to the statement. The column type will come from Types.
        Overrides:
        setNull in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalDate

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

        public java.time.LocalDate getLocalDate​(java.sql.ResultSet rs,
                                                int column)
                                         throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalDate java type.
        Overrides:
        getLocalDate in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalTime

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

        public java.time.LocalTime getLocalTime​(java.sql.ResultSet rs,
                                                int column)
                                         throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalTime java type.
        Overrides:
        getLocalTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalDateTime

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

        public java.time.LocalDateTime getLocalDateTime​(java.sql.ResultSet rs,
                                                        int column)
                                                 throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalDateTime java type.
        Overrides:
        getLocalDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setOffsetDateTime

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

        public java.time.OffsetDateTime getOffsetDateTime​(java.sql.ResultSet rs,
                                                          int column)
                                                   throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper OffsetDateTime java type.
        Overrides:
        getOffsetDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • getClobString

        public java.lang.String getClobString​(java.sql.ResultSet rs,
                                              int column)
                                       throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getClobString in class DBDictionary
        Throws:
        java.sql.SQLException
      • getTimestamp

        public java.sql.Timestamp getTimestamp​(java.sql.ResultSet rs,
                                               int column,
                                               java.util.Calendar cal)
                                        throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getTimestamp in class DBDictionary
        Throws:
        java.sql.SQLException
      • getObject

        public java.lang.Object getObject​(java.sql.ResultSet rs,
                                          int column,
                                          java.util.Map map)
                                   throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getObject in class DBDictionary
        Throws:
        java.sql.SQLException
      • getColumns

        public Column[] getColumns​(java.sql.DatabaseMetaData meta,
                                   java.lang.String catalog,
                                   java.lang.String schemaName,
                                   java.lang.String tableName,
                                   java.lang.String columnName,
                                   java.sql.Connection conn)
                            throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to find columns matching the given table and column patterns.
        Overrides:
        getColumns in class DBDictionary
        Throws:
        java.sql.SQLException
      • getPreferredType

        public int getPreferredType​(int type)
        Oracle JDBC is still Java7 at most :(
        Overrides:
        getPreferredType in class DBDictionary
      • getPrimaryKeys

        public PrimaryKey[] getPrimaryKeys​(java.sql.DatabaseMetaData meta,
                                           java.lang.String catalog,
                                           java.lang.String schemaName,
                                           java.lang.String tableName,
                                           java.sql.Connection conn)
                                    throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to find primary keys for the given table pattern.
        Overrides:
        getPrimaryKeys in class DBDictionary
        Throws:
        java.sql.SQLException
      • getIndexInfo

        public Index[] getIndexInfo​(java.sql.DatabaseMetaData meta,
                                    java.lang.String catalog,
                                    java.lang.String schemaName,
                                    java.lang.String tableName,
                                    boolean unique,
                                    boolean approx,
                                    java.sql.Connection conn)
                             throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to find indexes matching the given table pattern.
        Overrides:
        getIndexInfo in class DBDictionary
        Throws:
        java.sql.SQLException
      • getIndexInfo

        public Index[] getIndexInfo​(java.sql.DatabaseMetaData meta,
                                    DBIdentifier catalog,
                                    DBIdentifier schemaName,
                                    DBIdentifier tableName,
                                    boolean unique,
                                    boolean approx,
                                    java.sql.Connection conn)
                             throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to find indexes matching the given table pattern.
        Overrides:
        getIndexInfo in class DBDictionary
        Throws:
        java.sql.SQLException
      • getImportedKeys

        public ForeignKey[] getImportedKeys​(java.sql.DatabaseMetaData meta,
                                            java.lang.String catalog,
                                            java.lang.String schemaName,
                                            java.lang.String tableName,
                                            java.sql.Connection conn,
                                            boolean partialKeys)
                                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to return full foreign keys imported by the given table pattern.
        Overrides:
        getImportedKeys in class DBDictionary
        Throws:
        java.sql.SQLException
      • getImportedKeys

        public ForeignKey[] getImportedKeys​(java.sql.DatabaseMetaData meta,
                                            DBIdentifier catalog,
                                            DBIdentifier schemaName,
                                            DBIdentifier tableName,
                                            java.sql.Connection conn,
                                            boolean partialKeys)
                                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Reflect on the schema to return full foreign keys imported by the given table pattern.
        Overrides:
        getImportedKeys 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
      • getJDBCType

        public int getJDBCType​(int metaTypeCode,
                               boolean lob,
                               int precis,
                               int scale,
                               boolean xml)
        Return the preferred Types constant for the given JavaTypes or JavaSQLTypes constant.
        Overrides:
        getJDBCType in class DBDictionary
      • getSequencesSQL

        protected java.lang.String getSequencesSQL​(java.lang.String schemaName,
                                                   java.lang.String sequenceName)
        Description copied from class: DBDictionary
        Return the SQL needed to select the list of sequences.
        Overrides:
        getSequencesSQL in class DBDictionary
      • isSystemSequence

        public boolean isSystemSequence​(java.lang.String name,
                                        java.lang.String schema,
                                        boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.
        Overrides:
        isSystemSequence in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • isSystemSequence

        public boolean isSystemSequence​(DBIdentifier name,
                                        DBIdentifier schema,
                                        boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.
        Overrides:
        isSystemSequence in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • getGeneratedKeyTriggerName

        protected java.lang.String getGeneratedKeyTriggerName​(Column col)
        Trigger name for simulating auto-assign values on the given column.
      • getOpenJPA3GeneratedKeySequenceName

        protected java.lang.String getOpenJPA3GeneratedKeySequenceName​(Column col)
        Returns a OpenJPA 3-compatible name for an auto-assign sequence.
      • getOpenJPA3GeneratedKeyTriggerName

        protected java.lang.String getOpenJPA3GeneratedKeyTriggerName​(Column col)
        Returns a OpenJPA 3-compatible name for an auto-assign trigger.
      • putBytes

        public void putBytes​(java.sql.Blob blob,
                             byte[] data)
                      throws java.sql.SQLException
        Invoke Oracle's putBytes method on the given BLOB object. Uses reflection in case the blob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.
        Overrides:
        putBytes in class DBDictionary
        Throws:
        java.sql.SQLException
      • putString

        public void putString​(java.sql.Clob clob,
                              java.lang.String data)
                       throws java.sql.SQLException
        Invoke Oracle's putString method on the given CLOB object. Uses reflection in case the clob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.
        Overrides:
        putString in class DBDictionary
        Throws:
        java.sql.SQLException
      • putChars

        public void putChars​(java.sql.Clob clob,
                             char[] data)
                      throws java.sql.SQLException
        Invoke Oracle's putChars method on the given CLOB object. Uses reflection in case the clob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.
        Overrides:
        putChars in class DBDictionary
        Throws:
        java.sql.SQLException
      • appendXmlComparison

        public void appendXmlComparison​(SQLBuffer buf,
                                        java.lang.String op,
                                        FilterValue lhs,
                                        FilterValue rhs,
                                        boolean lhsxml,
                                        boolean rhsxml)
        If this dictionary supports XML type, use this method to append xml predicate.
        Overrides:
        appendXmlComparison in class DBDictionary
        Parameters:
        buf - the SQL buffer to write the comparison
        op - the comparison operation to perform
        lhs - the left hand side of the comparison
        rhs - the right hand side of the comparison
      • insertClobForStreamingLoad

        public void insertClobForStreamingLoad​(Row row,
                                               Column col,
                                               java.lang.Object ob)
                                        throws java.sql.SQLException
        Overrides:
        insertClobForStreamingLoad in class DBDictionary
        Throws:
        java.sql.SQLException
      • getBatchUpdateCount

        public int getBatchUpdateCount​(java.sql.PreparedStatement ps)
                                throws java.sql.SQLException
        Description copied from class: DBDictionary
        Return batched statements update success count
        Overrides:
        getBatchUpdateCount in class DBDictionary
        Parameters:
        ps - A PreparedStatement
        Returns:
        return update count
        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.
      • getMarkerForInsertUpdate

        public java.lang.String getMarkerForInsertUpdate​(Column col,
                                                         java.lang.Object val)
        Oracle requires special handling of XML column. Unless the value length is less or equal to 4000 bytes, the parameter marker must be decorated with type constructor.
        Overrides:
        getMarkerForInsertUpdate in class DBDictionary
        Parameters:
        col - column definition
        val - value to be inserted/updated
        Returns:
        parameter marker
      • guessJDBCVersion

        protected void guessJDBCVersion​(java.sql.Connection conn)
        Oracle drivers, at least in versions 10.2.0.4 and 11.2.0.1, incorrectly return a driver major version from DatabaseMetaData.getJDBCMajorVersion().
      • 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