org.apache.openjpa.jdbc.sql
Class DBDictionary

java.lang.Object
  extended by org.apache.openjpa.jdbc.sql.DBDictionary
All Implemented Interfaces:
JoinSyntaxes, Configurable, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler
Direct Known Subclasses:
AbstractDB2Dictionary, AbstractSQLServerDictionary, AccessDictionary, CacheDictionary, EmpressDictionary, FoxProDictionary, H2Dictionary, HSQLDictionary, InformixDictionary, InterbaseDictionary, JDataStoreDictionary, MySQLDictionary, OracleDictionary, PointbaseDictionary, PostgresDictionary

public class DBDictionary
extends Object
implements Configurable, ConnectionDecorator, JoinSyntaxes, LoggingConnectionDecorator.SQLWarningHandler

Class which allows the creation of SQL dynamically, in a database agnostic fashion. Subclass for the nuances of different data stores.


Nested Class Summary
static class DBDictionary.SerializedData
          Used by some mappings to represent data that has already been serialized so that we don't have to serialize multiple times.
 
Field Summary
 boolean allowsAliasInBulkClause
           
 String arrayTypeName
           
 String autoAssignClause
           
 String autoAssignTypeName
           
 int batchLimit
           
 String bigintTypeName
           
 String binaryTypeName
           
 String bitLengthFunction
           
 String bitTypeName
           
 int blobBufferSize
           
 String blobTypeName
           
 String booleanTypeName
           
 String castFunction
           
 String catalogSeparator
           
protected static int CENTI
           
 int characterColumnSize
           
 String charTypeName
           
 int clobBufferSize
           
 String clobTypeName
           
 String closePoolSQL
           
 String concatenateDelimiter
           
 String concatenateFunction
           
protected  JDBCConfiguration conf
           
protected  boolean connected
           
static String CONS_NAME_AFTER
           
static String CONS_NAME_BEFORE
           
static String CONS_NAME_MID
           
 String constraintNameMode
           
 boolean createPrimaryKeys
           
 String crossJoinClause
           
 String currentDateFunction
           
 String currentTimeFunction
           
 String currentTimestampFunction
           
 int datePrecision
           
 String dateTypeName
           
protected static int DECI
           
 String decimalTypeName
           
 String distinctCountColumnSeparator
           
 String distinctTypeName
           
 String doubleTypeName
           
 String driverVendor
           
 String dropTableSQL
           
static List EMPTY_STRING_LIST
           
 String fixedSizeTypeNames
           
protected  Set fixedSizeTypeNameSet
           
 String floatTypeName
           
 String forUpdateClause
           
 String getStringVal
           
 int inClauseLimit
           
 String initializationSQL
           
 String innerJoinClause
           
 String integerTypeName
           
 String javaObjectTypeName
           
 int joinSyntax
           
 String lastGeneratedKeyQuery
           
protected  Log log
           
 String longVarbinaryTypeName
           
 String longVarcharTypeName
           
 int maxAutoAssignNameLength
           
 int maxColumnNameLength
           
 int maxConstraintNameLength
           
 int maxEmbeddedBlobSize
           
 int maxEmbeddedClobSize
           
 int maxIndexesPerTable
           
 int maxIndexNameLength
           
 int maxTableNameLength
           
protected static int MICRO
           
protected static int MILLI
           
protected static int NAME_ANY
           
protected static int NAME_SEQUENCE
           
protected static int NAME_TABLE
           
protected static int NANO
           
 String nextSequenceQuery
           
protected static int NO_BATCH
           
 String nullTypeName
           
 String numericTypeName
           
 String otherTypeName
           
 String outerJoinClause
           
 String platform
           
protected static int RANGE_POST_DISTINCT
           
protected static int RANGE_POST_LOCK
           
protected static int RANGE_POST_SELECT
           
protected static int RANGE_PRE_DISTINCT
           
 int rangePosition
           
 String realTypeName
           
 String refTypeName
           
 boolean requiresAliasForSubselect
           
 boolean requiresAutoCommitForMetaData
           
 boolean requiresCastForComparisons
           
 boolean requiresCastForMathFunctions
           
 boolean requiresConditionForCrossJoin
           
 boolean requiresTargetForDelete
           
 String reservedWords
           
protected  Set reservedWordSet
           
static String SCHEMA_CASE_LOWER
           
static String SCHEMA_CASE_PRESERVE
           
static String SCHEMA_CASE_UPPER
           
 String schemaCase
           
 String searchStringEscape
           
protected static int SEC
           
 String selectWords
           
protected  Set selectWordSet
          If a native query begins with any of the values found here then it will be treated as a select statement.
 String sequenceNameSQL
           
 String sequenceSchemaSQL
           
 String sequenceSQL
           
 boolean simulateLocking
           
 String smallintTypeName
           
static List[] SQL_STATE_CODES
           
 boolean storageLimitationsFatal
           
 boolean storeCharsAsNumbers
           
 boolean storeLargeNumbersAsStrings
           
 String stringLengthFunction
           
 String structTypeName
           
 String substringFunctionName
           
 boolean supportsAlterTableWithAddColumn
           
 boolean supportsAlterTableWithDropColumn
           
 boolean supportsAutoAssign
           
 boolean supportsCascadeDeleteAction
           
 boolean supportsCascadeUpdateAction
           
 boolean supportsComments
           
 boolean supportsCorrelatedSubselect
           
 boolean supportsDefaultDeleteAction
           
 boolean supportsDefaultUpdateAction
           
 boolean supportsDeferredConstraints
           
 boolean supportsForeignKeys
           
 boolean supportsHaving
           
 boolean supportsLockingWithDistinctClause
           
 boolean supportsLockingWithInnerJoin
           
 boolean supportsLockingWithMultipleTables
           
 boolean supportsLockingWithOrderClause
           
 boolean supportsLockingWithOuterJoin
           
 boolean supportsLockingWithSelectRange
           
 boolean supportsModOperator
           
 boolean supportsMultipleNontransactionalResultSets
           
 boolean supportsNullDeleteAction
           
 boolean supportsNullTableForGetColumns
           
 boolean supportsNullTableForGetImportedKeys
           
 boolean supportsNullTableForGetIndexInfo
           
 boolean supportsNullTableForGetPrimaryKeys
           
 boolean supportsNullUpdateAction
           
 boolean supportsQueryTimeout
           
 boolean supportsRestrictDeleteAction
           
 boolean supportsRestrictUpdateAction
           
 boolean supportsSchemaForGetColumns
           
 boolean supportsSchemaForGetTables
           
 boolean supportsSelectEndIndex
           
 boolean supportsSelectForUpdate
           
 boolean supportsSelectStartIndex
           
 boolean supportsSubselect
           
 boolean supportsTimestampNanos
           
 boolean supportsUniqueConstraints
           
 boolean supportsXMLColumn
           
 String systemSchemas
           
protected  Set systemSchemaSet
           
 String systemTables
           
protected  Set systemTableSet
           
 String tableForUpdateClause
           
 String tableTypes
           
 String timestampTypeName
           
 String timeTypeName
           
 String tinyintTypeName
           
 String toLowerCaseFunction
           
 String toUpperCaseFunction
           
 String trimBothFunction
           
 String trimLeadingFunction
           
 String trimTrailingFunction
           
protected  Set typeModifierSet
           
protected static int UNLIMITED
           
 boolean useGetBestRowIdentifierForPrimaryKeys
           
 boolean useGetBytesForBlobs
           
 boolean useGetObjectForBlobs
           
 boolean useGetStringForClobs
           
 boolean useSchemaName
           
 boolean useSetBytesForBlobs
           
 boolean useSetStringForClobs
           
 String validationSQL
           
 String varbinaryTypeName
           
 String varcharTypeName
           
static String VENDOR_DATADIRECT
           
static String VENDOR_OTHER
           
 String xmlTypeName
           
 
Fields inherited from interface org.apache.openjpa.jdbc.sql.JoinSyntaxes
SYNTAX_DATABASE, SYNTAX_SQL92, SYNTAX_TRADITIONAL
 
Constructor Summary
DBDictionary()
           
 
Method Summary
 String addCastAsType(String func, Val val)
          add CAST for a function operator where operand is a param
 void appendCast(SQLBuffer buf, Object val, int type)
          Cast the specified value to the specified type.
protected  void appendLength(SQLBuffer buf, int type)
           
protected  void appendNumericCast(SQLBuffer buf, FilterValue val)
          Append SQL for the given numeric value to the buffer, casting as needed.
protected  void appendSelect(SQLBuffer selectSQL, Object elem, Select sel, int idx)
          Append elem to selectSQL.
protected  void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)
          If this dictionary can select ranges, use this method to append the range SQL.
protected  String appendSize(Column col, String typeName)
          Helper method to add size properties to the specified type.
protected  void appendUpdates(Select sel, JDBCStore store, SQLBuffer sql, Object[] params, Map updateParams, boolean allowAlias)
           
 void appendXmlComparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs, boolean lhsxml, boolean rhsxml)
          If this dictionary supports XML type, use this method to append xml predicate.
 void assertSupport(boolean feature, String property)
          Assert that the given dictionary flag is true.
protected  void calculateValue(Val val, Select sel, ExpContext ctx, ExpState state, Path path, ExpState pathState)
          This method is to provide override for non-JDBC or JDBC-like implementation of calculating value.
 boolean canOuterJoin(int syntax, ForeignKey fk)
          Returns if the given foreign key can be eagerly loaded using other joins.
 void closeDataSource(DataSource dataSource)
          Closes the specified DataSource and releases any resources associated with it.
protected  StringBuffer comment(StringBuffer buf, String comment)
           
 void comparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs)
          Append a comparison.
 void connectedConfiguration(Connection conn)
          This method is called when the dictionary first sees any connection.
protected  String convertSchemaCase(String objectName)
          Convert the specified schema name to a name that the database will be able to understand.
protected  long copy(InputStream in, OutputStream out)
           
protected  long copy(Reader reader, Writer writer)
           
 void createIndexIfNecessary(Schema schema, String table, Column pkColumn)
          Create an index if necessary for some database tables
 Connection decorate(Connection conn)
          Decorate the given connection if needed.
 void deleteStream(JDBCStore store, Select sel)
           
 void endConfiguration()
          Invoked upon completion of bean property configuration for this object.
protected  ResultSet executeQuery(Connection conn, PreparedStatement stmnt, String sql)
          This method is to provide override for non-JDBC or JDBC-like implementation of executing query.
 String[] getAddColumnSQL(Column column)
          Return a series of SQL statements to add the given column to its table.
 String[] getAddForeignKeySQL(ForeignKey fk)
          Return a series of SQL statements to add the given foreign key to its table.
 String[] getAddPrimaryKeySQL(PrimaryKey pk)
          Return a series of SQL statements to add the given primary key to its table.
 Array getArray(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 InputStream getAsciiStream(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 int getBatchLimit()
          Return the batchLimit
 BigDecimal getBigDecimal(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 BigInteger getBigInteger(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 InputStream getBinaryStream(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Blob getBlob(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Object getBlobObject(ResultSet rs, int column, JDBCStore store)
          Convert the specified column of the SQL ResultSet to the proper java type.
 boolean getBoolean(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 byte getByte(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 byte[] getBytes(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Calendar getCalendar(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 String getCastFunction(Val val, String func)
          Attach CAST to the current function if necessary
protected  String getCatalogNameForMetadata(String catalogName)
          Returns the catalog name that will be used for obtaining information from DatabaseMetaData.
 char getChar(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Reader getCharacterStream(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Clob getClob(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 String getClobString(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
protected  String getColumnNameForMetadata(String columnName)
          Returns the column name that will be used for obtaining information from DatabaseMetaData.
 Column[] getColumns(DatabaseMetaData meta, String catalog, String schemaName, String tableName, String columnName, Connection conn)
          Reflect on the schema to find columns matching the given table and column patterns.
 String[] getCreateIndexSQL(Index index)
          Return a series of SQL statements to create the given index.
 String[] getCreateSequenceSQL(Sequence seq)
          Return a series of SQL statements to create the given sequence.
 String[] getCreateTableSQL(Table table)
          Return a series of SQL statements to create the given table, complete with columns.
 Date getDate(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Date getDate(ResultSet rs, int column, Calendar cal)
          Convert the specified column of the SQL ResultSet to the proper java type.
protected  String getDeclareColumnSQL(Column col, boolean alter)
          Return the declaration SQL for the given column.
 String[] getDeleteTableContentsSQL(Table[] tables)
          Create SQL to delete the contents of the specified tables.
protected  SQLBuffer getDeleteTargets(Select sel)