org.apache.openjpa.jdbc.sql
Class DB2Dictionary

java.lang.Object
  extended by org.apache.openjpa.jdbc.sql.DBDictionary
      extended by org.apache.openjpa.jdbc.sql.AbstractDB2Dictionary
          extended by org.apache.openjpa.jdbc.sql.DB2Dictionary
All Implemented Interfaces:
JoinSyntaxes, Configurable, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler

public class DB2Dictionary
extends AbstractDB2Dictionary

Dictionary for IBM DB2 database.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
DBDictionary.SerializedData
 
Field Summary
protected  String databaseProductName
           
protected  String databaseProductVersion
           
protected static int db2ISeriesV5R3OrEarlier
           
protected static int db2ISeriesV5R4OrLater
           
protected  int db2ServerType
           
protected static int db2UDBV81OrEarlier
           
protected static int db2UDBV82OrLater
           
protected static int db2ZOSV8xOrLater
           
protected  int maj
           
protected  int min
           
 String optimizeClause
           
 String rowClause
           
 
Fields inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
allowsAliasInBulkClause, arrayTypeName, autoAssignClause, autoAssignTypeName, bigintTypeName, binaryTypeName, bitLengthFunction, bitTypeName, blobTypeName, booleanTypeName, castFunction, catalogSeparator, CENTI, characterColumnSize, charTypeName, clobTypeName, closePoolSQL, concatenateDelimiter, concatenateFunction, conf, connected, CONS_NAME_AFTER, CONS_NAME_BEFORE, CONS_NAME_MID, constraintNameMode, createPrimaryKeys, crossJoinClause, currentDateFunction, currentTimeFunction, currentTimestampFunction, datePrecision, dateTypeName, DECI, decimalTypeName, distinctCountColumnSeparator, distinctTypeName, doubleTypeName, driverVendor, dropTableSQL, fixedSizeTypeNames, fixedSizeTypeNameSet, floatTypeName, forUpdateClause, getStringVal, inClauseLimit, initializationSQL, innerJoinClause, integerTypeName, javaObjectTypeName, joinSyntax, lastGeneratedKeyQuery, log, longVarbinaryTypeName, longVarcharTypeName, maxAutoAssignNameLength, maxColumnNameLength, maxConstraintNameLength, maxEmbeddedBlobSize, maxEmbeddedClobSize, maxIndexesPerTable, maxIndexNameLength, maxTableNameLength, MICRO, MILLI, NAME_ANY, NAME_SEQUENCE, NAME_TABLE, NANO, nextSequenceQuery, nullTypeName, numericTypeName, otherTypeName, outerJoinClause, platform, RANGE_POST_DISTINCT, RANGE_POST_LOCK, RANGE_POST_SELECT, RANGE_PRE_DISTINCT, rangePosition, realTypeName, refTypeName, requiresAliasForSubselect, requiresAutoCommitForMetaData, requiresCastForComparisons, requiresCastForMathFunctions, requiresConditionForCrossJoin, reservedWords, reservedWordSet, SCHEMA_CASE_LOWER, SCHEMA_CASE_PRESERVE, SCHEMA_CASE_UPPER, schemaCase, searchStringEscape, SEC, sequenceNameSQL, sequenceSchemaSQL, sequenceSQL, simulateLocking, smallintTypeName, storageLimitationsFatal, storeCharsAsNumbers, storeLargeNumbersAsStrings, stringLengthFunction, structTypeName, substringFunctionName, supportsAlterTableWithAddColumn, supportsAlterTableWithDropColumn, supportsAutoAssign, supportsCascadeDeleteAction, supportsCascadeUpdateAction, supportsCorrelatedSubselect, supportsDefaultDeleteAction, supportsDefaultUpdateAction, supportsDeferredConstraints, supportsForeignKeys, supportsHaving, supportsLockingWithDistinctClause, supportsLockingWithInnerJoin, supportsLockingWithMultipleTables, supportsLockingWithOrderClause, supportsLockingWithOuterJoin, supportsLockingWithSelectRange, supportsModOperator, supportsMultipleNontransactionalResultSets, supportsNullDeleteAction, supportsNullTableForGetColumns, supportsNullTableForGetImportedKeys, supportsNullTableForGetIndexInfo, supportsNullTableForGetPrimaryKeys, supportsNullUpdateAction, supportsQueryTimeout, supportsRestrictDeleteAction, supportsRestrictUpdateAction, supportsSchemaForGetColumns, supportsSchemaForGetTables, supportsSelectEndIndex, supportsSelectForUpdate, supportsSelectStartIndex, supportsSubselect, supportsTimestampNanos, supportsUniqueConstraints, supportsXMLColumn, systemSchemas, systemSchemaSet, systemTables, systemTableSet, tableForUpdateClause, tableTypes, timestampTypeName, timeTypeName, tinyintTypeName, toLowerCaseFunction, toUpperCaseFunction, trimBothFunction, trimLeadingFunction, trimTrailingFunction, useGetBestRowIdentifierForPrimaryKeys, useGetBytesForBlobs, useGetObjectForBlobs, useGetStringForClobs, useSchemaName, useSetBytesForBlobs, useSetStringForClobs, validationSQL, varbinaryTypeName, varcharTypeName, VENDOR_DATADIRECT, VENDOR_OTHER, xmlTypeName
 
Fields inherited from interface org.apache.openjpa.jdbc.sql.JoinSyntaxes
SYNTAX_DATABASE, SYNTAX_SQL92, SYNTAX_TRADITIONAL
 
Constructor Summary
DB2Dictionary()
           
 
Method Summary
 String addCastAsType(String func, Val val)
          add CAST for a function operator where operand is a param
protected  void appendLength(SQLBuffer buf, int type)
           
protected  void appendSelectRange(SQLBuffer buf, long start, long end)
          If this dictionary can select ranges, use this method to append the range SQL.
 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 connectedConfiguration(Connection conn)
          This method is called when the dictionary first sees any connection.
 Connection decorate(Connection conn)
          Decorate the given connection if needed.
 String getCastFunction(Val val, String func)
          Return the correct CAST function syntax
 String[] getCreateSequenceSQL(Sequence seq)
          Return a series of SQL statements to create the given sequence.
 int getDb2ServerType()
           
protected  String getForUpdateClause(JDBCFetchConfiguration fetch, boolean forUpdate)
          Get the update clause for the query based on the updateClause and isolationLevel hints
protected  String getSequencesSQL(String schemaName, String sequenceName)
          Return the SQL needed to select the list of sequences.
 void indexOf(SQLBuffer buf, FilterValue str, FilterValue find, FilterValue start)
          Invoke this database's indexOf function.
 boolean isDB2ISeriesV5R3OrEarlier()
           
 boolean isDB2ISeriesV5R4OrLater()
           
 boolean isDB2UDBV81OrEarlier()
           
 boolean isDB2UDBV82OrLater()
           
 boolean isDB2ZOSV8xOrLater()
           
 OpenJPAException newStoreException(String msg, SQLException[] causes, Object failed)
          Return a new exception that wraps causes.
 boolean supportsRandomAccessResultSet(Select sel, boolean forUpdate)
          Return false if the given select requires a forward-only result set.
 SQLBuffer toSelect(Select sel, boolean forUpdate, JDBCFetchConfiguration fetch)
          Create a SELECT statement in the proper join syntax for the given instance.
 
Methods inherited from class org.apache.openjpa.jdbc.sql.AbstractDB2Dictionary
substring
 
Methods inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
appendCast, appendNumericCast, appendSize, appendUpdates, assertSupport, canOuterJoin, closeDataSource, comparison, convertSchemaCase, endConfiguration, getAddColumnSQL, getAddForeignKeySQL, getAddPrimaryKeySQL, getArray, getAsciiStream, getBigDecimal, getBigInteger, getBinaryStream, getBlob, getBlobObject, getBoolean, getByte, getBytes, getCalendar, getCatalogNameForMetadata, getChar, getCharacterStream, getClob, getClobString, getColumnNameForMetadata, getColumns, getCreateIndexSQL, getCreateTableSQL, getDate, getDate, getDeclareColumnSQL, getDeleteTableContentsSQL, getDouble, getDropColumnSQL, getDropForeignKeySQL, getDropIndexSQL, getDropPrimaryKeySQL, getDropSequenceSQL, getDropTableSQL, getFloat, getForeignKeyConstraintSQL, getFrom, getFromSelect, getFullName, getFullName, getFullName, getGeneratedKey, getGeneratedKeySequenceName, getImportedKeys, getIndexInfo, getInt, getJDBCType, getLocale, getLong, getNumber, getObject, getPlaceholderValueString, getPreferredType, getPrimaryKeyConstraintSQL, getPrimaryKeys, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromGetPrimaryKeys, getRef, getSchemaNameForMetadata, getSelectOperation, getSelects, getSequences, getShort, getString, getTableNameForMetadata, getTables, getTime, getTimestamp, getTypeName, getTypeName, getUniqueConstraintSQL, getValidColumnName, getValidForeignKeyName, getValidIndexName, getValidPrimaryKeyName, getValidSequenceName, getValidTableName, getValidUniqueName, getVersionColumn, getWhere, handleWarning, isSystemIndex, isSystemSequence, isSystemTable, makeNameValid, mathFunction, newColumn, newForeignKey, newIndex, newPrimaryKey, newSequence, newTable, putBytes, putChars, putString, refSchemaComponents, serialize, setArray, setAsciiStream, setBigDecimal, setBigInteger, setBinaryStream, setBlob, setBlobObject, setBoolean, setByte, setBytes, setCalendar, setChar, setCharacterStream, setClob, setClobString, setConfiguration, setDate, setDate, setDouble, setFloat, setInt, setJoinSyntax, setLocale, setLong, setNull, setNumber, setObject, setRef, setShort, setString, setTime, setTimestamp, setTyped, setUnknown, shorten, startConfiguration, storageWarning, supportsDeleteAction, supportsLocking, supportsUpdateAction, toBulkOperation, toDelete, toNativeJoin, toOperation, toSelect, toSelectCount, toSQL92Join, toTraditionalJoin, toUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

optimizeClause

public String optimizeClause

rowClause

public String rowClause

db2ServerType

protected int db2ServerType

db2ISeriesV5R3OrEarlier

protected static final int db2ISeriesV5R3OrEarlier
See Also:
Constant Field Values

db2UDBV81OrEarlier

protected static final int db2UDBV81OrEarlier
See Also:
Constant Field Values

db2ZOSV8xOrLater

protected static final int db2ZOSV8xOrLater
See Also:
Constant Field Values

db2UDBV82OrLater

protected static final int db2UDBV82OrLater
See Also:
Constant Field Values

db2ISeriesV5R4OrLater

protected static final int db2ISeriesV5R4OrLater
See Also:
Constant Field Values

databaseProductName

protected String databaseProductName

databaseProductVersion

protected String databaseProductVersion

maj

protected int maj

min

protected int min
Constructor Detail

DB2Dictionary

public DB2Dictionary()
Method Detail

supportsRandomAccessResultSet

public boolean supportsRandomAccessResultSet(Select sel,
                                             boolean forUpdate)
Description copied from class: DBDictionary
Return false if the given select requires a forward-only result set.

Overrides:
supportsRandomAccessResultSet in class DBDictionary

appendSelectRange

protected void appendSelectRange(SQLBuffer buf,
                                 long start,
                                 long end)
Description copied from class: DBDictionary
If this dictionary can select ranges, use this method to append the range SQL.

Overrides:
appendSelectRange in class DBDictionary

getCreateSequenceSQL

public String[] getCreateSequenceSQL(Sequence seq)
Description copied from class: DBDictionary
Return a series of SQL statements to create the given sequence. Returns CREATE SEQUENCE <sequence name>[ START WITH <start>] [ INCREMENT BY <increment>] by default.

Overrides:
getCreateSequenceSQL in class DBDictionary

getSequencesSQL

protected String getSequencesSQL(String schemaName,
                                 String sequenceName)
Description copied from class: DBDictionary
Return the SQL needed to select the list of sequences.

Overrides:
getSequencesSQL in class DBDictionary

decorate

public Connection decorate(Connection conn)
                    throws 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 decoreate the connection.

Specified by:
decorate in interface ConnectionDecorator
Overrides:
decorate in class DBDictionary
Throws:
SQLException

connectedConfiguration

public void connectedConfiguration(Connection conn)
                            throws 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:
SQLException

getForUpdateClause

protected String getForUpdateClause(JDBCFetchConfiguration fetch,
                                    boolean forUpdate)
Get the update clause for the query based on the updateClause and isolationLevel hints

Overrides:
getForUpdateClause in class DBDictionary

isDB2UDBV82OrLater

public boolean isDB2UDBV82OrLater()
                           throws SQLException
Throws:
SQLException

isDB2ZOSV8xOrLater

public boolean isDB2ZOSV8xOrLater()
                           throws SQLException
Throws:
SQLException

isDB2ISeriesV5R3OrEarlier

public boolean isDB2ISeriesV5R3OrEarlier()
                                  throws SQLException
Throws:
SQLException

isDB2ISeriesV5R4OrLater

public boolean isDB2ISeriesV5R4OrLater()
                                throws SQLException
Throws:
SQLException

isDB2UDBV81OrEarlier

public boolean isDB2UDBV81OrEarlier()
                             throws SQLException
Throws:
SQLException

toSelect

public SQLBuffer toSelect(Select sel,
                          boolean forUpdate,
                          JDBCFetchConfiguration fetch)
Description copied from class: DBDictionary
Create a SELECT statement in the proper join syntax for the given instance.

Overrides:
toSelect in class DBDictionary

newStoreException

public OpenJPAException newStoreException(String msg,
                                          SQLException[] causes,
                                          Object failed)
Description copied from class: DBDictionary
Return a new exception that wraps causes. However, the details of exactly what type of exception is returned can be determined by the implementation. This may take into account DB-specific exception information in causes.

Overrides:
newStoreException in class DBDictionary

getDb2ServerType

public int getDb2ServerType()

appendLength

protected void appendLength(SQLBuffer buf,
                            int type)
Overrides:
appendLength in class DBDictionary

appendXmlComparison

public 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.

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
lhsxml - indicates whether the left operand maps to xml
rhsxml - indicates whether the right operand maps to xml

addCastAsType

public String addCastAsType(String func,
                            Val val)
add CAST for a function operator where operand is a param

Overrides:
addCastAsType in class DBDictionary
Parameters:
func - function name
val - type
Returns:
updated string (func)

getCastFunction

public String getCastFunction(Val val,
                              String func)
Return the correct CAST function syntax

Overrides:
getCastFunction in class DBDictionary
Parameters:
val - operand of cast
func - original string
Returns:
a String with the correct CAST function syntax

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 AbstractDB2Dictionary
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


Copyright © 2006-2007 Apache Software Foundation. All Rights Reserved.