Package org.apache.openjpa.jdbc.sql
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
DBDictionary.DateMillisecondBehaviors, DBDictionary.SerializedData
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringalterSequenceSQLprotected java.lang.StringalterSequenceSQLFB15protected java.lang.StringalterSequenceSQLFB20protected java.lang.StringcreateSequenceSQLprotected java.lang.StringcreateSequenceSQLFB15protected java.lang.StringcreateSequenceSQLFB20protected java.lang.StringdropSequenceSQLFB15static intFB_VERSION_15static intFB_VERSION_20static intFB_VERSION_21intfirebirdVersionintindexedVarcharMaxSizeFB15protected longmaxRowNumberInRangestatic java.lang.StringRANGE_SYNTAX_FIRST_SKIPstatic java.lang.StringRANGE_SYNTAX_ROWSjava.lang.StringrangeSyntax-
Fields inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
_procs, _proxyManager, allowQueryTimeoutOnFindUpdate, allowsAliasInBulkClause, arrayTypeName, autoAssignClause, autoAssignTypeName, batchLimit, bigintTypeName, binaryTypeName, bitLengthFunction, bitTypeName, blobBufferSize, blobTypeName, booleanRepresentation, booleanTypeName, castFunction, catalogSeparator, CENTI, characterColumnSize, charTypeName, clobBufferSize, clobTypeName, closePoolSQL, concatenateDelimiter, concatenateFunction, conf, connected, CONS_NAME_AFTER, CONS_NAME_BEFORE, CONS_NAME_MID, constraintNameMode, createPrimaryKeys, crossJoinClause, currentDateFunction, currentTimeFunction, currentTimestampFunction, databaseProductName, databaseProductVersion, dateFractionDigits, datePrecision, dateTypeName, DECI, decimalTypeName, defaultSchemaName, delimitedCase, disableAlterSeqenceIncrementBy, disableSchemaFactoryColumnTypeErrors, distinctCountColumnSeparator, distinctTypeName, doubleTypeName, driverVendor, dropTableSQL, fixedSizeTypeNames, fixedSizeTypeNameSet, floatTypeName, forUpdateClause, fractionalTypeNameSet, fullResultCollectionInOrderByRelation, getStringVal, inClauseLimit, indexPhysicalForeignKeys, initializationSQL, innerJoinClause, integerTypeName, invalidColumnWordSet, isJDBC3, isJDBC4, javaObjectTypeName, javaToDbColumnNameProcessing, joinSyntax, lastGeneratedKeyQuery, leadingDelimiter, log, longVarbinaryTypeName, longVarcharTypeName, maxAutoAssignNameLength, maxColumnNameLength, maxConstraintNameLength, maxEmbeddedBlobSize, maxEmbeddedClobSize, maxIndexesPerTable, maxIndexNameLength, maxTableNameLength, MICRO, MILLI, NAME_ANY, NAME_SEQUENCE, NAME_TABLE, nameConcatenator, NANO, nativeSequenceType, nextSequenceQuery, NO_BATCH, nullTypeName, numericTypeName, otherTypeName, outerJoinClause, platform, RANGE_POST_DISTINCT, RANGE_POST_LOCK, RANGE_POST_SELECT, RANGE_PRE_DISTINCT, rangePosition, realTypeName, refTypeName, reportsSuccessNoInfoOnBatchUpdates, requiresAliasForSubselect, requiresAutoCommitForMetaData, requiresCastForComparisons, requiresCastForMathFunctions, requiresConditionForCrossJoin, requiresSearchStringEscapeForLike, requiresTargetForDelete, reservedWords, reservedWordSet, roundTimeToMillisec, SCHEMA_CASE_LOWER, SCHEMA_CASE_PRESERVE, SCHEMA_CASE_UPPER, schemaCase, searchStringEscape, SEC, selectWords, selectWordSet, sequenceNameSQL, sequenceSchemaSQL, sequenceSQL, setStringRightTruncationOn, simulateLocking, smallintTypeName, sqlStateCodes, storageLimitationsFatal, storeCharsAsNumbers, storeLargeNumbersAsStrings, stringLengthFunction, structTypeName, substringFunctionName, supportsAlterTableWithAddColumn, supportsAlterTableWithDropColumn, supportsAutoAssign, supportsCascadeDeleteAction, supportsCascadeUpdateAction, supportsCaseConversionForLob, supportsComments, supportsCorrelatedSubselect, supportsDefaultDeleteAction, supportsDefaultUpdateAction, supportsDeferredConstraints, supportsDelimitedIdentifiers, supportsForeignKeys, supportsForeignKeysComposite, supportsGeneralCaseExpression, supportsGetGeneratedKeys, supportsHaving, supportsLockingWithDistinctClause, supportsLockingWithInnerJoin, supportsLockingWithMultipleTables, supportsLockingWithOrderClause, supportsLockingWithOuterJoin, supportsLockingWithSelectRange, supportsModOperator, supportsMultipleNontransactionalResultSets, supportsNullDeleteAction, supportsNullTableForGetColumns, supportsNullTableForGetImportedKeys, supportsNullTableForGetIndexInfo, supportsNullTableForGetPrimaryKeys, supportsNullUniqueColumn, supportsNullUpdateAction, supportsParameterInSelect, supportsQueryTimeout, supportsRestrictDeleteAction, supportsRestrictUpdateAction, supportsSchemaForGetColumns, supportsSchemaForGetTables, supportsSelectEndIndex, supportsSelectForUpdate, supportsSelectFromFinalTable, supportsSelectStartIndex, supportsSimpleCaseExpression, supportsSubselect, supportsUniqueConstraints, supportsXMLColumn, systemSchemas, systemSchemaSet, systemTables, systemTableSet, tableForUpdateClause, tableLengthIncludesSchema, tableTypes, timestampTypeName, timestampWithZoneTypeName, timeTypeName, timeWithZoneTypeName, tinyintTypeName, toLowerCaseFunction, toUpperCaseFunction, trailingDelimiter, trimBothFunction, trimLeadingFunction, trimSchemaName, trimStringColumns, trimTrailingFunction, typeModifierSet, UNLIMITED, useGetBestRowIdentifierForPrimaryKeys, useGetBytesForBlobs, useGetObjectForBlobs, useGetStringForClobs, useJDBC4SetBinaryStream, useNativeSequenceCache, useSchemaName, useSetBytesForBlobs, useSetStringForClobs, useWildCardForCount, validationSQL, varbinaryTypeName, varcharTypeName, VENDOR_DATADIRECT, VENDOR_OTHER, xmlTypeEncoding, xmlTypeName
-
Fields inherited from interface org.apache.openjpa.jdbc.sql.JoinSyntaxes
SYNTAX_DATABASE, SYNTAX_SQL92, SYNTAX_TRADITIONAL
-
-
Constructor Summary
Constructors Constructor Description FirebirdDictionary()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)Use eitherFIRST <p> SKIP <q>orROWS <m> TO <n>syntax.protected java.lang.StringappendSize(Column col, java.lang.String typeName)On Firebird 1.5 reduce the size of indexedVARCHARcolumn to 252 or a value specified by user. 252 is the maximum Firebird 1.5 can handle for one-column indexes.voidconnectedConfiguration(java.sql.Connection conn)Determine Firebird version and configure itself accordingly.protected intdetermineFirebirdVersion(java.sql.Connection con)Determine Firebird version either by using JDBC 3 methods or, if they are not available, by parsing the value returned by DatabaseMetaData.getDatabaseProductVersion().protected voiddetermineRangeSyntax()Determine range syntax to be used depending on Firebird version.protected java.lang.StringgetColumnNameForMetadata(java.lang.String columnName)Return%ifcolumnNameisnull, otherwise delegate to super implementation.java.lang.String[]getCreateSequenceSQL(Sequence seq)Return eitherCREATE SEQUENCE <sequence name>orCREATE GENERATOR <sequence name>.java.lang.String[]getDropColumnSQL(Column column)ReturnALTER TABLE <table name> DROP <col name>.java.lang.String[]getDropSequenceSQL(Sequence seq)On Firebird 1.5 returnDROP GENERATOR <sequence name>.java.lang.StringgetPlaceholderValueString(Column col)Return<value> AS <type>.protected java.lang.StringgetSequencesSQL(java.lang.String schemaName, java.lang.String sequenceName)Return Firebird-specific statement to select the list of sequences.protected java.lang.StringgetSequencesSQL(DBIdentifier schemaName, DBIdentifier sequenceName)protected java.lang.StringgetTableNameForMetadata(java.lang.String tableName)Return%iftableNameisnull, otherwise delegate to super implementation.protected java.lang.StringgetTableNameForMetadata(DBIdentifier tableName)Returns the table name that will be used for obtaining information fromDatabaseMetaData.voidindexOf(SQLBuffer buf, FilterValue str, FilterValue find, FilterValue start)On Firebird 2.1 returnPOSITION(<find>, <str> [, <start>]).protected intmatchErrorState(java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>> errorStates, java.sql.SQLException ex)Use error code as SQL state returned by Firebird is ambiguous.protected SequencenewSequence(java.sql.ResultSet sequenceMeta)Call super implementation and trim sequence name.voidsubstring(SQLBuffer buf, FilterValue str, FilterValue start, FilterValue length)UseSUBSTRING(<col name> FROM <m> FOR <n>).-
Methods inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
addCastAsType, addErrorCode, appendCast, appendLength, appendNumericCast, appendSelect, appendUpdates, appendXmlComparison, applyRange, assertSupport, calculateValue, canOuterJoin, closeDataSource, combineForeignKey, comment, comparison, configureNamingRules, convertSchemaCase, convertSchemaCase, copy, copy, createIndexIfNecessary, createIndexIfNecessary, decorate, deleteStream, delimitAll, endConfiguration, executeQuery, fromDBName, getAddColumnSQL, getAddForeignKeySQL, getAddPrimaryKeySQL, getAlterSequenceSQL, getArray, getAsciiStream, getBatchFetchSize, getBatchLimit, getBatchUpdateCount, getBigDecimal, getBigInteger, getBinaryStream, getBlob, getBlobObject, getBoolean, getBooleanRepresentation, getByte, getBytes, getCalendar, getCastFunction, getCastFunction, getCatalogNameForMetadata, getCatalogNameForMetadata, getChar, getCharacterStream, getClob, getClobString, getColumnDBName, getColumnIdentifier, getColumnNameForMetadata, getColumns, getColumns, getConversionKey, getCreateIndexSQL, getCreateTableSQL, getCreateTableSQL, getDate, getDate, getDateFractionDigits, getDeclareColumnSQL, getDefaultIdentifierRule, getDefaultSchemaName, getDeleteTableContentsSQL, getDeleteTargets, getDelimitedCase, getDelimitIdentifiers, getDouble, getDropForeignKeySQL, getDropIndexSQL, getDropPrimaryKeySQL, getDropTableSQL, getFloat, getForeignKeyConstraintSQL, getForUpdateClause, getFrom, getFromSelect, getFullIdentifier, getFullName, getFullName, getFullName, getGeneratedKey, getGeneratedKeySequenceName, getGenKeySeqName, getIdentifierConcatenator, getIdentifierDelimiter, getIdentifierRule, getIdentifierRules, getIdentityColumnName, getImportedKeys, getImportedKeys, getImportedKeys, getImportedKeys, getIndexInfo, getIndexInfo, getInt, getInvalidColumnWordSet, getIsNotNullSQL, getIsNullSQL, getJDBCType, getJDBCType, getJDBCType, getKey, getLeadingDelimiter, getLOBStream, getLocalDate, getLocalDateTime, getLocale, getLocalTime, getLog, getLong, getMajorVersion, getMarkerForInsertUpdate, getMillisecondBehavior, getMinorVersion, getNamingUtil, getNumber, getObject, getOffsetDateTime, getOffsetTime, getPreferredType, getPrimaryKeyConstraintSQL, getPrimaryKeys, getPrimaryKeys, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromGetPrimaryKeys, getPrimaryKeysFromGetPrimaryKeys, getRef, getSchemaCase, getSchemaNameForMetadata, getSchemaNameForMetadata, getSelectOperation, getSelects, getSelectTableAliases, getSequence, getSequences, getSequences, getShort, getStoredProcedure, getString, getSupportsDelimitedIdentifiers, getSupportsXMLColumn, getTables, getTables, getTime, getTimestamp, getTrailingDelimiter, getTrimSchemaName, getTypeName, getTypeName, getUniqueConstraintSQL, getValidColumnName, getValidColumnName, getValidColumnName, getValidColumnName, getValidForeignKeyName, getValidForeignKeyName, getValidIndexName, getValidIndexName, getValidPrimaryKeyName, getValidSequenceName, getValidSequenceName, getValidTableName, getValidTableName, getValidUniqueName, getValidUniqueName, getVersionColumn, getVersionColumn, getWhere, getXMLTypeEncoding, handleWarning, insertBlobForStreamingLoad, insertClobForStreamingLoad, insertSize, isFatalException, isImplicitJoin, isSelect, isSystemIndex, isSystemIndex, isSystemSequence, isSystemSequence, isSystemSequence, isSystemTable, isSystemTable, isUsingLimit, isUsingOffset, isUsingOrderBy, isUsingRange, makeNameValid, makeNameValid, makeNameValid, makeNameValid, mathFunction, needsToCreateIndex, needsToCreateIndex, newColumn, newForeignKey, newIndex, newPrimaryKey, newStoreException, newTable, prepareStatement, processDBColumnName, putBytes, putChars, putString, refSchemaComponents, serialize, setArray, setAsciiStream, setBatchLimit, setBigDecimal, setBigInteger, setBinaryStream, setBlob, setBlobObject, setBoolean, setBooleanRepresentation, setByte, setBytes, setCalendar, setChar, setCharacterStream, setClob, setClobString, setConfiguration, setDate, setDate, setDateMillisecondBehavior, setDefaultSchemaName, setDelimitedCase, setDelimitIdentifiers, setDouble, setFloat, setInt, setJoinSyntax, setLeadingDelimiter, setLocalDate, setLocalDateTime, setLocale, setLocalTime, setLong, setMajorVersion, setMinorVersion, setNull, setNumber, setObject, setOffsetDateTime, setOffsetTime, setQueryTimeout, setRef, setShort, setStatementQueryTimeout, setString, setSupportsDelimitedIdentifiers, setSupportsXMLColumn, setTime, setTimeouts, setTimeouts, setTimestamp, setTrailingDelimiter, setTrimSchemaName, setTyped, setUnknown, setUnknown, setXMLTypeEncoding, shorten, startConfiguration, storageWarning, supportsDeferredForeignKeyConstraints, supportsDeferredUniqueConstraints, supportsDeleteAction, supportsIsolationForUpdate, supportsLocking, supportsRandomAccessResultSet, supportsUpdateAction, toBulkOperation, toDBName, toDBName, toDelete, toNativeJoin, toOperation, toOperation, toSelect, toSelect, toSelect, toSelect, toSelect, toSelectCount, toSnakeCase, toSQL92Join, toTraditionalJoin, toUpdate, updateBlob, updateClob, validateBatchProcess, validateDBSpecificBatchProcess, versionEqualOrEarlierThan, versionEqualOrLaterThan, versionLaterThan
-
-
-
-
Field Detail
-
firebirdVersion
public int firebirdVersion
-
indexedVarcharMaxSizeFB15
public int indexedVarcharMaxSizeFB15
-
rangeSyntax
public java.lang.String rangeSyntax
-
maxRowNumberInRange
protected long maxRowNumberInRange
-
alterSequenceSQLFB15
protected java.lang.String alterSequenceSQLFB15
-
alterSequenceSQLFB20
protected java.lang.String alterSequenceSQLFB20
-
createSequenceSQLFB15
protected java.lang.String createSequenceSQLFB15
-
createSequenceSQLFB20
protected java.lang.String createSequenceSQLFB20
-
dropSequenceSQLFB15
protected java.lang.String dropSequenceSQLFB15
-
alterSequenceSQL
protected java.lang.String alterSequenceSQL
-
createSequenceSQL
protected java.lang.String createSequenceSQL
-
FB_VERSION_15
public static final int FB_VERSION_15
- See Also:
- Constant Field Values
-
FB_VERSION_20
public static final int FB_VERSION_20
- See Also:
- Constant Field Values
-
FB_VERSION_21
public static final int FB_VERSION_21
- See Also:
- Constant Field Values
-
RANGE_SYNTAX_FIRST_SKIP
public static final java.lang.String RANGE_SYNTAX_FIRST_SKIP
- See Also:
- Constant Field Values
-
RANGE_SYNTAX_ROWS
public static final java.lang.String RANGE_SYNTAX_ROWS
- See Also:
- Constant Field Values
-
-
Method Detail
-
connectedConfiguration
public void connectedConfiguration(java.sql.Connection conn) throws java.sql.SQLExceptionDetermine Firebird version and configure itself accordingly.- Overrides:
connectedConfigurationin classDBDictionary- Throws:
java.sql.SQLException
-
appendSelectRange
protected void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)
Use eitherFIRST <p> SKIP <q>orROWS <m> TO <n>syntax. IfROWSvariant is used andendequalsLong.MAX_VALUE, a constant is used as<n>value.- Overrides:
appendSelectRangein classDBDictionary
-
determineFirebirdVersion
protected int determineFirebirdVersion(java.sql.Connection con) throws java.sql.SQLExceptionDetermine 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:
java.sql.SQLException
-
determineRangeSyntax
protected void determineRangeSyntax()
Determine range syntax to be used depending on Firebird version. User can override range syntax.
-
getPlaceholderValueString
public java.lang.String getPlaceholderValueString(Column col)
Return<value> AS <type>.- Overrides:
getPlaceholderValueStringin classDBDictionary
-
getTableNameForMetadata
protected java.lang.String getTableNameForMetadata(java.lang.String tableName)
Return%iftableNameisnull, otherwise delegate to super implementation.- Overrides:
getTableNameForMetadatain classDBDictionary
-
getTableNameForMetadata
protected java.lang.String getTableNameForMetadata(DBIdentifier tableName)
Description copied from class:DBDictionaryReturns the table name that will be used for obtaining information fromDatabaseMetaData.- Overrides:
getTableNameForMetadatain classDBDictionary
-
getColumnNameForMetadata
protected java.lang.String getColumnNameForMetadata(java.lang.String columnName)
Return%ifcolumnNameisnull, otherwise delegate to super implementation.- Overrides:
getColumnNameForMetadatain classDBDictionary
-
getDropColumnSQL
public java.lang.String[] getDropColumnSQL(Column column)
ReturnALTER TABLE <table name> DROP <col name>.- Overrides:
getDropColumnSQLin classDBDictionary
-
getCreateSequenceSQL
public java.lang.String[] getCreateSequenceSQL(Sequence seq)
Return eitherCREATE SEQUENCE <sequence name>orCREATE GENERATOR <sequence name>. If initial value of sequence is set, return also an appropriateALTERstatement.- Overrides:
getCreateSequenceSQLin classDBDictionary
-
getSequencesSQL
protected java.lang.String getSequencesSQL(java.lang.String schemaName, java.lang.String sequenceName)Return Firebird-specific statement to select the list of sequences.- Overrides:
getSequencesSQLin classDBDictionary
-
getSequencesSQL
protected java.lang.String getSequencesSQL(DBIdentifier schemaName, DBIdentifier sequenceName)
- Overrides:
getSequencesSQLin classDBDictionary
-
newSequence
protected Sequence newSequence(java.sql.ResultSet sequenceMeta) throws java.sql.SQLException
Call super implementation and trim sequence name. This is because of trailing spaces problem:RDB$GENERATORS.RDB$GENERATOR_NAMEisCHAR(31)and usingRTRIMUDF function on Firebird 1.5 surprisingly returns a string right-padded with spaces up to the length of 255.- Overrides:
newSequencein classDBDictionary- Throws:
java.sql.SQLException
-
getDropSequenceSQL
public java.lang.String[] getDropSequenceSQL(Sequence seq)
On Firebird 1.5 returnDROP GENERATOR <sequence name>. On Firebird 2.0 and later delegate to the super implementation.- Overrides:
getDropSequenceSQLin classDBDictionary
-
indexOf
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find, FilterValue start)
On Firebird 2.1 returnPOSITION(<find>, <str> [, <start>]). On older versions throwUnsupportedException- no suitable function exists.- Overrides:
indexOfin classDBDictionary- Parameters:
buf- the SQL buffer to write the indexOf invocation tostr- a query value representing the target stringfind- a query value representing the search stringstart- 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)
UseSUBSTRING(<col name> FROM <m> FOR <n>). Parameters are inlined because neither parameter binding nor expressions are accepted by Firebird here. As a result, anUnsupportedExceptionis thrown when something else than a constant is used instartorlength.- Overrides:
substringin classDBDictionary- Parameters:
buf- the SQL buffer to write the substring invocation tostr- a query value representing the target stringstart- a query value representing the start indexlength- a query value representing the length of substring, or null for none
-
appendSize
protected java.lang.String appendSize(Column col, java.lang.String typeName)
On Firebird 1.5 reduce the size of indexedVARCHARcolumn 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:
appendSizein classDBDictionary
-
matchErrorState
protected int matchErrorState(java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>> errorStates, java.sql.SQLException ex)Use error code as SQL state returned by Firebird is ambiguous.- Overrides:
matchErrorStatein classDBDictionary- Parameters:
errorStates- classification of SQL error states by their specific nature. The keys of the map represent one of the constants defined inStoreException. The value corresponding to a key represent the set of SQL Error States representing specific category of database error. This supplied map is sourced fromsql-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.
-
-