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
           
static int db2ISeriesV5R3OrEarlier
           
static int db2ISeriesV5R4OrLater
           
protected  int db2ServerType
           
static int db2UDBV81OrEarlier
           
static int db2UDBV82OrLater
           
static int db2ZOSV8xOrLater
           
protected  int maj
           
protected  int min
           
 String optimizeClause
           
 String rowClause
           
 
Fields inherited from class org.apache.openjpa.jdbc.sql.AbstractDB2Dictionary
varcharCastLength
 
Fields inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
allowsAliasInBulkClause, arrayTypeName, autoAssignClause, autoAssignTypeName, batchLimit, bigintTypeName, binaryTypeName, bitLengthFunction, bitTypeName, blobBufferSize, blobTypeName, 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, datePrecision, dateTypeName, DECI, decimalTypeName, distinctCountColumnSeparator, distinctTypeName, doubleTypeName, driverVendor, dropTableSQL, EMPTY_STRING_LIST, 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, NO_BATCH, 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, requiresTargetForDelete, reservedWords, reservedWordSet, SCHEMA_CASE_LOWER, SCHEMA_CASE_PRESERVE, SCHEMA_CASE_UPPER, schemaCase, searchStringEscape, SEC, selectWords, selectWordSet, sequenceNameSQL, sequenceSchemaSQL, sequenceSQL, simulateLocking, smallintTypeName, SQL_STATE_CODES, storageLimitationsFatal, storeCharsAsNumbers, storeLargeNumbersAsStrings, stringLengthFunction, structTypeName, substringFunctionName, supportsAlterTableWithAddColumn, supportsAlterTableWithDropColumn, supportsAutoAssign, supportsCascadeDeleteAction, supportsCascadeUpdateAction, supportsComments, 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, typeModifierSet, UNLIMITED, 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
 void appendCast(SQLBuffer buf, FilterValue val, int type)
          Cast the specified value to the specified type.
protected  void appendLength(SQLBuffer buf, int type)
           
protected  void appendSelect(SQLBuffer selectSQL, Object alias, 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.
 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.
 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.
 int getBatchLimit()
          Return the batch limit.
 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 isForUpdate, Select sel)
          Get the update clause for the query based on the updateClause and isolationLevel hints
protected  String getOptimizeClause(Select sel)
           
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.
 
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, calculateValue, canOuterJoin, closeDataSource, comment, comparison, convertSchemaCase, copy, copy, deleteStream, endConfiguration, executeQuery, 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, getDeleteTargets, getDouble, getDropColumnSQL, getDropForeignKeySQL, getDropIndexSQL, getDropPrimaryKeySQL, getDropSequenceSQL, getDropTableSQL, getFloat, getForeignKeyConstraintSQL, getFrom, getFromSelect, getFullName, getFullName, getFullName, getGeneratedKey, getGeneratedKeySequenceName, getImportedKeys, getIndexInfo, getInt, getJDBCType, getKey, getLOBStream, getLocale, getLong, getNumber, getObject, getPlaceholderValueString, getPreferredType, getPrimaryKeyConstraintSQL, getPrimaryKeys, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromGetPrimaryKeys, getRef, getSchemaCase, getSchemaNameForMetadata, getSelectOperation, getSelects, getSequence, getSequences, getShort, getSQLStates, getString, getTableNameForMetadata, getTables, getTime, getTimestamp, getTypeName, getTypeName, getUniqueConstraintSQL, getValidColumnName, getValidColumnName, getValidForeignKeyName, getValidIndexName, getValidPrimaryKeyName, getValidSequenceName, getValidTableName, getValidUniqueName, getVersionColumn, getWhere, handleWarning, insertBlobForStreamingLoad, insertClobForStreamingLoad, insertSize, isSelect, isSystemIndex, isSystemSequence, isSystemTable, makeNameValid, makeNameValid, mathFunction, newColumn, newForeignKey, newIndex, newPrimaryKey, newSequence, newTable, prepareStatement, putBytes, putChars, putString, refSchemaComponents, serialize, setArray, setAsciiStream, setBatchLimit, 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, supportsDeferredForeignKeyConstraints, supportsDeferredUniqueConstraints, supportsDeleteAction, supportsLocking, supportsUpdateAction, toBulkOperation, toDelete, toNativeJoin, toOperation, toOperation, toSelect, toSelect, toSelect, toSelect, toSelect, toSelectCount, toSQL92Join, toTraditionalJoin, toUpdate, updateBlob, updateClob, validateBatchProcess, validateDBSpecificBatchProcess
 
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

public static final int db2ISeriesV5R3OrEarlier
See Also:
Constant Field Values

db2UDBV81OrEarlier

public static final int db2UDBV81OrEarlier
See Also:
Constant Field Values

db2ZOSV8xOrLater

public static final int db2ZOSV8xOrLater
See Also:
Constant Field Values

db2UDBV82OrLater

public static final int db2UDBV82OrLater
See Also:
Constant Field Values

db2ISeriesV5R4OrLater

public 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,
                                 boolean subselect)
Description copied from class: DBDictionary
If this dictionary can select ranges, use this method to append the range SQL.

Overrides:
appendSelectRange in class DBDictionary

appendSelect

protected void appendSelect(SQLBuffer selectSQL,
                            Object alias,
                            Select sel,
                            int idx)
Description copied from class: DBDictionary
Append elem to selectSQL.

Overrides:
appendSelect in class DBDictionary
Parameters:
selectSQL - The SQLBuffer to append to.

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 isForUpdate,
                                    Select sel)
Get the update clause for the query based on the updateClause and isolationLevel hints

Overrides:
getForUpdateClause in class DBDictionary

isDB2UDBV82OrLater

public boolean isDB2UDBV82OrLater()

isDB2ZOSV8xOrLater

public boolean isDB2ZOSV8xOrLater()

isDB2ISeriesV5R3OrEarlier

public boolean isDB2ISeriesV5R3OrEarlier()

isDB2ISeriesV5R4OrLater

public boolean isDB2ISeriesV5R4OrLater()

isDB2UDBV81OrEarlier

public boolean isDB2UDBV81OrEarlier()

getOptimizeClause

protected String getOptimizeClause(Select sel)

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)

getBatchLimit

public int getBatchLimit()
Return the batch limit. If the batchLimit is -1, change it to 100 for best performance

Overrides:
getBatchLimit in class DBDictionary

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

appendCast

public void appendCast(SQLBuffer buf,
                       FilterValue val,
                       int type)
Cast the specified value to the specified type.

Parameters:
buf - the buffer to append the cast to
val - the value to cast
type - the type of the case, e.g. Types.NUMERIC

createIndexIfNecessary

public void createIndexIfNecessary(Schema schema,
                                   String table,
                                   Column pkColumn)
Create an index if necessary for some database tables

Overrides:
createIndexIfNecessary in class DBDictionary


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