Class DefaultDBTranslator
java.lang.Object
com.inductiveautomation.ignition.gateway.db.DefaultDBTranslator
- All Implemented Interfaces:
DBTranslator
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.gateway.db.DBTranslator
DBTranslator.Tokens -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected LimitPositionprotected intprotected Stringprotected Stringprotected booleanprotected String -
Constructor Summary
ConstructorsConstructorDescriptionDefaultDBTranslator(com.inductiveautomation.ignition.gateway.datasource.config.DbTranslatorResource resource) DefaultDBTranslator(String cTable, String cAISeq, String cAITrig, String cNdx, String autoInc, String lDef, LimitPosition lPos, String aTable, String aTableColumn, String pKey, String qCurTime, Map<DataType, String> tMap, String colQuoteChar, boolean supportsRgk, String fetchRgkQuery, String tableListFilter) DefaultDBTranslator(Map<DataType, String> tMap) -
Method Summary
Modifier and TypeMethodDescriptionapplyLimit(String query, Integer limit) Takes a SELECT query and applies the given limit to it, resulting in a select query with a limiting clause.getAlterCommand(String tableName, ColumnList columns) Returns the character that this driver uses to quote names in queriesgetCreateCommand(String tableName, ColumnList columns) getCreateIndexCommand(String tableName, Column column) protected StringgetCreationDef(ColumnList columns) Returns a query that can be used to get the current database time.protected StringgetDataTypeKeyword(DataType type) getFetchKeyQuery(String tableName, String columnName) A query to be executed instead of using JDBC's built-in facility for obtaining auto-generated keys.protected StringgetShortendName(String name) protected StringgetSpecialtyDef(String tokenVal, String definition, String token) Returns a filter that will be used to narrow the list of tables returned from the database.static booleanReturns whethere-- or any exception chained viaSQLException.getNextException()(e.g.static booleanisNativeBooleanType(String columnType) Returns whether the given SQL column-type keyword denotes a native boolean column -- one that requires a real boolean bind rather than an integer0/1.booleanprobeNativeBooleanColumns(Connection con, String probeSql, LoggerEx log) Reads the column types of the table selected byprobeSql(aSELECT ... WHERE 1 = 0statement) and classifies each as a native boolean SQL type (isNativeBooleanType(java.lang.String)), keyed by lower-cased column name.quoteColumn(Column col) quoteColumn(String col) protected StringreplaceToken(String source, String token, String value) protected StringbooleanWhether this translator mapsDataType.Booleanto a native boolean SQL type -- one that requires a real boolean bind rather than an integer0/1.static booleanusesNativeBooleanType(DBTranslator translator) Null-safe access toDBTranslator.usesNativeBooleanType()(see that method for the fallback semantics);falsefor anulltranslator.
-
Field Details
-
createTable
-
createAISequence
-
createAITrigger
-
createIndex
-
autoIncTypeDef
-
limitDef
-
limitPos
-
alterTable
-
alterColumnDef
-
-
currentTimeQuery
-
columnQuoteChar
-
supportsRgk
protected boolean supportsRgk -
readGKQuery
-
tableListFilter
-
maxIdentifierLength
protected int maxIdentifierLength -
typeMap
-
-
Constructor Details
-
DefaultDBTranslator
public DefaultDBTranslator() -
DefaultDBTranslator
-
DefaultDBTranslator
public DefaultDBTranslator(String cTable, String cAISeq, String cAITrig, String cNdx, String autoInc, String lDef, LimitPosition lPos, String aTable, String aTableColumn, String pKey, String qCurTime, Map<DataType, String> tMap, String colQuoteChar, boolean supportsRgk, String fetchRgkQuery, String tableListFilter) -
DefaultDBTranslator
public DefaultDBTranslator(com.inductiveautomation.ignition.gateway.datasource.config.DbTranslatorResource resource)
-
-
Method Details
-
createTypeMap
-
getCurrentTimeQuery
Description copied from interface:DBTranslatorReturns a query that can be used to get the current database time.- Specified by:
getCurrentTimeQueryin interfaceDBTranslator
-
isNativeBooleanType
Returns whether the given SQL column-type keyword denotes a native boolean column -- one that requires a real boolean bind rather than an integer0/1. The keyword may come from a translator's type map (the keyword that lands in generated DDL) or be read back from the database via column metadata, so callers can classify a column's actual type the same way it is declared. Any spelling beginning withbool(e.g. PostgreSQL'sbool/BOOLEAN, including a value carrying a modifier such as"BOOLEAN NOT NULL") is native. SQL Server'sbitis intentionally excluded because it accepts an integer 0/1 bind. -
usesNativeBooleanType
Null-safe access toDBTranslator.usesNativeBooleanType()(see that method for the fallback semantics);falsefor anulltranslator. Must go through the interface method rather than aninstanceof DefaultDBTranslatorcheck because a datasource hands out a swap-able wrapper around the real translator, not theDefaultDBTranslatoritself. -
usesNativeBooleanType
public boolean usesNativeBooleanType()Description copied from interface:DBTranslatorWhether this translator mapsDataType.Booleanto a native boolean SQL type -- one that requires a real boolean bind rather than an integer0/1. This is the best available signal for the type a boolean column was most likely created with when the column's actual type cannot be read back from the database; it is consulted only as a fallback, since the mapping is mutable and can diverge from an already-created column. Defaults tofalse;DefaultDBTranslatoroverrides it to classify its configured boolean keyword, and any translator that wraps another (e.g. a datasource's swap-able delegate) must forward this call so the wrapped mapping is not lost.- Specified by:
usesNativeBooleanTypein interfaceDBTranslator
-
probeNativeBooleanColumns
public static Map<String,Boolean> probeNativeBooleanColumns(Connection con, String probeSql, LoggerEx log) Reads the column types of the table selected byprobeSql(aSELECT ... WHERE 1 = 0statement) and classifies each as a native boolean SQL type (isNativeBooleanType(java.lang.String)), keyed by lower-cased column name. The probe is isolated with a savepoint when the connection is not in auto-commit, so on PostgreSQL a probe failure -- which aborts the current transaction -- does not poison the write that follows. Returns an empty map if the column types cannot be read, in which case the caller falls back tousesNativeBooleanType(DBTranslator). -
isColumnTypeMismatch
Returns whethere-- or any exception chained viaSQLException.getNextException()(e.g. inside aBatchUpdateException) -- reports a column/parameter datatype mismatch, PostgreSQL SQLState42804. This is the signal that a cached native-boolean classification has gone stale (for instance the column was altered on a live gateway) and must be re-resolved; an unrelated failure should leave the cached classification intact rather than force a fresh metadata probe on every retry. -
quoteColumn
-
quoteColumn
-
getCreateCommand
- Specified by:
getCreateCommandin interfaceDBTranslator
-
applyLimit
Description copied from interface:DBTranslatorTakes a SELECT query and applies the given limit to it, resulting in a select query with a limiting clause. If the incoming query already has a limit clause, the existing text will be used (that is, nothing further will be done).- Specified by:
applyLimitin interfaceDBTranslator
-
getAlterCommand
- Specified by:
getAlterCommandin interfaceDBTranslator
-
getCreateIndexCommand
- Specified by:
getCreateIndexCommandin interfaceDBTranslator
-
getShortendName
-
getCreationDef
-
getSpecialtyDef
-
replaceToken
-
replaceTokens
-
getDataTypeKeyword
-
getColumnQuoteChar
Description copied from interface:DBTranslatorReturns the character that this driver uses to quote names in queries- Specified by:
getColumnQuoteCharin interfaceDBTranslator
-
getFetchKeyQuery
Description copied from interface:DBTranslatorA query to be executed instead of using JDBC's built-in facility for obtaining auto-generated keys. Only used if supportsRGK is false. Takes the table name and column name in case the query needs to use them- it will depend on the database as to whether or not they are.- Specified by:
getFetchKeyQueryin interfaceDBTranslator
-
isSupportsRGK
public boolean isSupportsRGK()- Specified by:
isSupportsRGKin interfaceDBTranslator- Returns:
- whether or not this driver supports returning generated keys on insert queries
-
getTableListFilter
Description copied from interface:DBTranslatorReturns a filter that will be used to narrow the list of tables returned from the database. A semi-colon separated list of simple patterns, like "apex_*;sys_info*"- Specified by:
getTableListFilterin interfaceDBTranslator
-