FileDocCategorySizeDatePackage
DatabasePlatform.javaAPI DocGlassfish v2 API78878Fri Jul 13 12:08:42 BST 2007oracle.toplink.essentials.internal.databaseaccess

DatabasePlatform

public class DatabasePlatform extends DatasourcePlatform
DatabasePlatform is private to TopLink. It encapsulates behavior specific to a database platform (eg. Oracle, Sybase, DBase), and provides protocol for TopLink to access this behavior. The behavior categories which require platform specific handling are SQL generation and sequence behavior. While database platform currently provides sequence number retrieval behaviour, this will move to a sequence manager (when it is implemented).
see
AccessPlatform
see
DB2Platform
see
DBasePlatform
see
OraclePlatform
see
SybasePlatform
since
TOPLink/Java 1.0

Fields Summary
protected transient Hashtable
fieldTypes
Holds a hashtable of values used to map JAVA types to database types for table creation
protected boolean
usesNativeSQL
Indicates that native SQL should be used for literal values instead of ODBC esacpe format Only used with Oracle, Sybase & DB2
protected boolean
usesByteArrayBinding
Indicates that binding will be used for BLOB data. NOTE: does not work well with ODBC.
protected boolean
shouldBindAllParameters
Bind all arguments to any SQL statement.
protected boolean
shouldCacheAllStatements
Cache all prepared statements, this requires full parameter binding as well.
protected int
statementCacheSize
The statement cache size for prepare parameterized statements.
protected boolean
shouldForceFieldNamesToUpperCase
Can be used if the app expects upper case but the database is not return consistent case, i.e. different databases.
protected boolean
shouldTrimStrings
Indicates (if true) to remove blanks characters from the right of CHAR strings.
protected boolean
usesStreamsForBinding
Indicates that streams will be used to store BLOB data. NOTE: does not work with ODBC
protected int
stringBindingSize
Indicates the size above which strings will be bound NOTE: does not work with ODBC
protected boolean
usesStringBinding
Indicates that strings will above the stringBindingSize will be bound NOTE: does not work with ODBC
protected int
cursorCode
Allow for the code that is used for preparing cursored outs for a storedprocedure to be settable.
protected int
transactionIsolation
The transaction isolation level to be set on the connection (optional).
protected boolean
supportsAutoCommit
Some JDBC drivers do not support AutoCommit in the way TopLink expects. (e.g. Attunity Connect, JConnect)
protected boolean
shouldOptimizeDataConversion
Allow for driver level data conversion optimization to be disabled, required because some drivers can loose precision.
protected transient Hashtable
classTypes
Stores mapping of class types to database types for schema creation.
protected static boolean
shouldIgnoreCaseOnFieldComparisons
Allow for case in field names to be ignored as some databases are not case sensitive and when using custom this can be an issue.
Constructors Summary
public DatabasePlatform()


      
        this.tableQualifier = "";
        this.usesNativeSQL = false;
        this.usesByteArrayBinding = true;
        this.usesStringBinding = false;
        this.stringBindingSize = 255;
        this.shouldTrimStrings = true;
        this.shouldBindAllParameters = false;
        this.shouldCacheAllStatements = false;
        this.shouldOptimizeDataConversion = true;
        this.statementCacheSize = 50;
        this.shouldForceFieldNamesToUpperCase = false;
        this.transactionIsolation = -1;
        this.cursorCode = -10;
        this.supportsAutoCommit = true;
    
Methods Summary
public booleanallowsSizeInProcedureArguments()
Used for sp defs.

        return true;
    
protected voidappendBoolean(java.lang.Boolean bool, java.io.Writer writer)
Appends a Boolean value as a number

        if (bool.booleanValue()) {
            writer.write("1");
        } else {
            writer.write("0");
        }
    
protected voidappendByteArray(byte[] bytes, java.io.Writer writer)
Append the ByteArray in ODBC literal format ({b hexString}). This limits the amount of Binary data by the length of the SQL. Binding should increase this limit.

        writer.write("{b '");
        Helper.writeHexString(bytes, writer);
        writer.write("'}");
    
protected voidappendCalendar(java.util.Calendar calendar, java.io.Writer writer)
Answer a platform correct string representation of a Calendar as a Timestamp, suitable for SQL generation. The calendar is printed in the ODBC platform independent timestamp format {ts'YYYY-MM-DD HH:MM:SS.NNNNNNNNN'}.

        writer.write("{ts '");
        writer.write(Helper.printCalendar(calendar));
        writer.write("'}");
    
protected voidappendDate(java.sql.Date date, java.io.Writer writer)
Answer a platform correct string representation of a Date, suitable for SQL generation. The date is printed in the ODBC platform independent format {d 'yyyy-mm-dd'}.

        writer.write("{d '");
        writer.write(Helper.printDate(date));
        writer.write("'}");
    
public voidappendLiteralToCall(oracle.toplink.essentials.queryframework.Call call, java.io.Writer writer, java.lang.Object literal)
INTERNAL In case shouldBindLiterals is true, instead of null value a DatabaseField value may be passed (so that it's type could be used for binding null).

        if(shouldBindLiterals()) {
            appendLiteralToCallWithBinding(call, writer, literal);
        } else {
            int nParametersToAdd = appendParameterInternal(call, writer, literal);
            for(int i=0; i < nParametersToAdd; i++ ) {
                ((DatabaseCall)call).getParameterTypes().addElement(DatabaseCall.LITERAL);
            }
        }
    
protected voidappendLiteralToCallWithBinding(oracle.toplink.essentials.queryframework.Call call, java.io.Writer writer, java.lang.Object literal)
INTERNAL Override this method in case the platform needs to do something special for binding literals. Note that instead of null value a DatabaseField value may be passed (so that it's type could be used for binding null).

        ((DatabaseCall)call).appendLiteral(writer, literal);
    
protected voidappendNumber(java.lang.Number number, java.io.Writer writer)
Write number to SQL string. This is provided so that database which do not support Exponential format can customize their printing.

        writer.write(number.toString());
    
public voidappendParameter(oracle.toplink.essentials.queryframework.Call call, java.io.Writer writer, java.lang.Object parameter)
Write a database-friendly representation of the given parameter to the writer. Determine the class of the object to be written, and invoke the appropriate print method for that object. The default is "toString". The platform may decide to bind some types, such as byte arrays and large strings. Should only be called in case binding is not used.

        appendParameterInternal(call, writer, parameter);
    
public intappendParameterInternal(oracle.toplink.essentials.queryframework.Call call, java.io.Writer writer, java.lang.Object parameter)
Returns the number of parameters that used binding. Should only be called in case binding is not used.

        int nBoundParameters = 0;
        DatabaseCall databaseCall = (DatabaseCall)call;
        try {
            // PERF: Print Calendars directly avoiding timestamp conversion,
            // Must be before conversion as you cannot bind calendars.
            if (parameter instanceof Calendar) {
                appendCalendar((Calendar)parameter, writer);
                return nBoundParameters;
            }
            Object dbValue = convertToDatabaseType(parameter);

            if (dbValue instanceof String) {// String and number first as they are most common.
                if (usesStringBinding() && (((String)dbValue).length() >= getStringBindingSize())) {
                    databaseCall.bindParameter(writer, dbValue);
                    nBoundParameters = 1;
                } else {
                    appendString((String)dbValue, writer);
                }
            } else if (dbValue instanceof Number) {
                appendNumber((Number)dbValue, writer);
            } else if (dbValue instanceof java.sql.Time) {
                appendTime((java.sql.Time)dbValue, writer);
            } else if (dbValue instanceof java.sql.Timestamp) {
                appendTimestamp((java.sql.Timestamp)dbValue, writer);
            } else if (dbValue instanceof java.sql.Date) {
                appendDate((java.sql.Date)dbValue, writer);
            } else if (dbValue == null) {
                writer.write("NULL");
            } else if (dbValue instanceof Boolean) {
                appendBoolean((Boolean)dbValue, writer);
            } else if (dbValue instanceof byte[]) {
                if (usesByteArrayBinding()) {
                    databaseCall.bindParameter(writer, dbValue);
                    nBoundParameters = 1;
                } else {
                    appendByteArray((byte[])dbValue, writer);
                }
            } else if (dbValue instanceof Vector) {
                nBoundParameters = printValuelist((Vector)dbValue, databaseCall, writer);
            } else if ((parameter instanceof Struct) || (parameter instanceof Array) || (parameter instanceof Ref)) {
                databaseCall.bindParameter(writer, parameter);
                nBoundParameters = 1;
            } else if (oracle.toplink.essentials.internal.helper.Helper.isCollection(dbValue)) {
                nBoundParameters = printValuelist(Helper.makeVectorFromObject(dbValue), databaseCall, writer);
            } else if (dbValue.getClass() == int[].class) {
                nBoundParameters = printValuelist((int[])dbValue, databaseCall, writer);
            } else if (dbValue instanceof AppendCallCustomParameter) {
                // custom append is required (example BLOB, CLOB on Oracle8)
                ((AppendCallCustomParameter)dbValue).append(writer);
                nBoundParameters = 1;
            } else if (dbValue instanceof BindCallCustomParameter) {
                // custom binding is required, object to be bound is wrapped (example NCHAR, NVARCHAR2, NCLOB on Oracle9)
                databaseCall.bindParameter(writer, dbValue);
                nBoundParameters = 1;
            } else if ((dbValue instanceof Struct) || (dbValue instanceof Array) || (dbValue instanceof Ref)) {
                databaseCall.bindParameter(writer, dbValue);
                nBoundParameters = 1;
            } else {
                // Assume database driver primitive that knows how to print itself, this is required for drivers
                // such as Oracle JDBC, Informix JDBC and others, as well as client specific classes.
                writer.write(dbValue.toString());
            }
        } catch (IOException exception) {
            throw ValidationException.fileError(exception);
        }
        
        return nBoundParameters;
    
protected voidappendString(java.lang.String string, java.io.Writer writer)
Write the string. Quotes must be double quoted.

        writer.write('\'");
        for (int position = 0; position < string.length(); position++) {
            if (string.charAt(position) == '\'") {
                writer.write("''");
            } else {
                writer.write(string.charAt(position));
            }
        }
        writer.write('\'");
    
protected voidappendTime(java.sql.Time time, java.io.Writer writer)
Answer a platform correct string representation of a Time, suitable for SQL generation. The time is printed in the ODBC platform independent format {t'hh:mm:ss'}.

        writer.write("{t '");
        writer.write(Helper.printTime(time));
        writer.write("'}");
    
protected voidappendTimestamp(java.sql.Timestamp timestamp, java.io.Writer writer)
Answer a platform correct string representation of a Timestamp, suitable for SQL generation. The timestamp is printed in the ODBC platform independent timestamp format {ts'YYYY-MM-DD HH:MM:SS.NNNNNNNNN'}.

        writer.write("{ts '");
        writer.write(Helper.printTimestamp(timestamp));
        writer.write("'}");
    
public voidautoCommit(oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor)
Used by JDBC drivers that do not support autocommit so simulate an autocommit.

        if (!supportsAutoCommit()) {
            accessor.getConnection().commit();
        }
    
public voidbeginTransaction(oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor)
Used for jdbc drivers which do not support autocommit to explicitly begin a transaction This method is a no-op for databases which implement autocommit as expected.

        if (!supportsAutoCommit()) {
            Statement statement = accessor.getConnection().createStatement();
            try {
                statement.executeUpdate("BEGIN TRANSACTION");
            } finally {
                statement.close();
            }
        }
    
public oracle.toplink.essentials.internal.databaseaccess.DatabaseCallbuildCallWithReturning(oracle.toplink.essentials.queryframework.SQLCall sqlCall, java.util.Vector returnFields)
INTERNAL Returns null unless the platform supports call with returning

        throw ValidationException.platformDoesNotSupportCallWithReturning(Helper.getShortClassName(this));
    
protected java.util.HashtablebuildClassTypes()
Return the mapping of class types to database types for the schema framework.

        Hashtable classTypeMapping;

        classTypeMapping = new Hashtable();
        //Key the dictionary the other way for table creation
        classTypeMapping.put("NUMBER", java.math.BigInteger.class);
        classTypeMapping.put("DECIMAL", java.math.BigDecimal.class);
        classTypeMapping.put("INTEGER", Integer.class);
        classTypeMapping.put("INT", Integer.class);
        classTypeMapping.put("NUMERIC", Long.class);
        classTypeMapping.put("FLOAT(16)", Float.class);
        classTypeMapping.put("FLOAT(32)", Double.class);
        classTypeMapping.put("NUMBER(1) default 0", Boolean.class);
        classTypeMapping.put("SHORT", Short.class);
        classTypeMapping.put("BYTE", Byte.class);
        classTypeMapping.put("DOUBLE", Double.class);
        classTypeMapping.put("FLOAT", Float.class);
        classTypeMapping.put("SMALLINT", Short.class);

        classTypeMapping.put("BIT", Boolean.class);
        classTypeMapping.put("SMALLINT DEFAULT 0", Boolean.class);

        classTypeMapping.put("VARCHAR", String.class);
        classTypeMapping.put("CHAR", Character.class);
        classTypeMapping.put("LONGVARBINARY", Byte[].class);
        classTypeMapping.put("TEXT", Character[].class);
        classTypeMapping.put("LONGTEXT", Character[].class);
        //	classTypeMapping.put("BINARY", Byte[].class);
        classTypeMapping.put("MEMO", Character[].class);
        classTypeMapping.put("VARCHAR2", String.class);
        classTypeMapping.put("LONG RAW", Byte[].class);
        classTypeMapping.put("LONG", Character[].class);

        classTypeMapping.put("DATE", java.sql.Date.class);
        classTypeMapping.put("TIMESTAMP", java.sql.Timestamp.class);
        classTypeMapping.put("TIME", java.sql.Time.class);
        classTypeMapping.put("DATETIME", java.sql.Timestamp.class);

        classTypeMapping.put("BIGINT", java.math.BigInteger.class);
        classTypeMapping.put("DOUBLE PRECIS", Double.class);
        classTypeMapping.put("IMAGE", Byte[].class);
        classTypeMapping.put("LONGVARCHAR", Character[].class);
        classTypeMapping.put("REAL", Float.class);
        classTypeMapping.put("TINYINT", Short.class);
        //	classTypeMapping.put("VARBINARY", Byte[].class);
        
        classTypeMapping.put("BLOB", Byte[].class);
        classTypeMapping.put("CLOB", Character[].class);

        return classTypeMapping;
    
protected java.util.HashtablebuildFieldTypes()
Return the mapping of class types to database types for the schema framework.

        Hashtable fieldTypeMapping;

        fieldTypeMapping = new Hashtable();
        fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("NUMBER", 1));

        fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("NUMBER", 10));
        fieldTypeMapping.put(Long.class, new FieldTypeDefinition("NUMBER", 19));
        fieldTypeMapping.put(Float.class, new FieldTypeDefinition("NUMBER", 12, 5).setLimits(19, 0, 19));
        fieldTypeMapping.put(Double.class, new FieldTypeDefinition("NUMBER", 10, 5).setLimits(19, 0, 19));
        fieldTypeMapping.put(Short.class, new FieldTypeDefinition("NUMBER", 5));
        fieldTypeMapping.put(Byte.class, new FieldTypeDefinition("NUMBER", 3));
        fieldTypeMapping.put(java.math.BigInteger.class, new FieldTypeDefinition("NUMBER", 19));
        fieldTypeMapping.put(java.math.BigDecimal.class, new FieldTypeDefinition("NUMBER", 19, 0).setLimits(19, 0, 19));

        fieldTypeMapping.put(String.class, new FieldTypeDefinition("VARCHAR"));
        fieldTypeMapping.put(Character.class, new FieldTypeDefinition("CHAR"));

        fieldTypeMapping.put(Byte[].class, new FieldTypeDefinition("BLOB"));
        fieldTypeMapping.put(Character[].class, new FieldTypeDefinition("CLOB"));
        fieldTypeMapping.put(byte[].class, new FieldTypeDefinition("BLOB"));
        fieldTypeMapping.put(char[].class, new FieldTypeDefinition("CLOB"));
        fieldTypeMapping.put(java.sql.Blob.class, new FieldTypeDefinition("BLOB"));
        fieldTypeMapping.put(java.sql.Clob.class, new FieldTypeDefinition("CLOB"));
        
        fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE"));
        fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMP"));
        fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("TIME"));

        return fieldTypeMapping;
    
public oracle.toplink.essentials.queryframework.ValueReadQuerybuildSelectQueryForNativeSequence()
INTERNAL:

        return null;
    
public oracle.toplink.essentials.queryframework.ValueReadQuerybuildSelectQueryForNativeSequence(java.lang.String seqName, java.lang.Integer size)
INTERNAL:

        return null;
    
public booleancanBuildCallWithReturning()
INTERNAL Indicates whether the platform can build call with returning. In case this method returns true, buildCallWithReturning method may be called.

        return false;
    
public voidcommitTransaction(oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor)
Used for jdbc drivers which do not support autocommit to explicitly commit a transaction This method is a no-op for databases which implement autocommit as expected.

        if (!supportsAutoCommit()) {
            accessor.getConnection().commit();
        }
    
public java.lang.ObjectconvertToDatabaseType(java.lang.Object value)
INTERNAL We support more primitive than JDBC does so we must do conversion before printing or binding. 2.0p22: protected->public INTERNAL

        if (value == null) {
            return null;
        }
        if (value.getClass() == ClassConstants.UTILDATE) {
            return Helper.timestampFromDate((java.util.Date)value);
        } else if (value instanceof Character) {
            return ((Character)value).toString();
        } else if (value instanceof Calendar) {
            return Helper.timestampFromDate(((Calendar)value).getTime());
        } else if (value instanceof BigInteger) {
            return new BigDecimal((BigInteger)value);
        } else if (value instanceof char[]) {
            return new String((char[])value);
        } else if (value instanceof Character[]) {
            return convertObject(value, ClassConstants.STRING);
        } else if (value instanceof Byte[]) {
            return convertObject(value, ClassConstants.APBYTE);
        }
        return value;
    
public voidcopyInto(oracle.toplink.essentials.internal.databaseaccess.Platform platform)
Copy the state into the new platform.

        super.copyInto(platform);
        if (!(platform instanceof DatabasePlatform)) {
            return;
        }
        DatabasePlatform databasePlatform = (DatabasePlatform)platform;
        databasePlatform.setShouldTrimStrings(shouldTrimStrings());
        databasePlatform.setUsesNativeSQL(usesNativeSQL());
        databasePlatform.setUsesByteArrayBinding(usesByteArrayBinding());
        databasePlatform.setUsesStringBinding(usesStringBinding());
        databasePlatform.setShouldBindAllParameters(shouldBindAllParameters());
        databasePlatform.setShouldCacheAllStatements(shouldCacheAllStatements());
        databasePlatform.setStatementCacheSize(getStatementCacheSize());
        databasePlatform.setTransactionIsolation(getTransactionIsolation());
        databasePlatform.setShouldForceFieldNamesToUpperCase(shouldForceFieldNamesToUpperCase());
        databasePlatform.setShouldOptimizeDataConversion(shouldOptimizeDataConversion());
        databasePlatform.setStringBindingSize(getStringBindingSize());
        databasePlatform.setUsesStreamsForBinding(usesStreamsForBinding());
    
protected oracle.toplink.essentials.sequencing.SequencecreatePlatformDefaultSequence()
INTERNAL: Create platform-default Sequence

        return new TableSequence();
    
public booleandontBindUpdateAllQueryUsingTempTables()
INTERNAL: May need to override this method if the sql generated for UpdateAllQuery using temp tables fails in case parameter binding is used.

        return false;
    
public java.lang.ObjectexecuteStoredProcedure(oracle.toplink.essentials.internal.databaseaccess.DatabaseCall dbCall, java.sql.PreparedStatement statement, oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession session)
because each platform has different requirements for accessing stored procedures and the way that we can combine resultsets and output params the stored procedure call is being executed on the platform

        Object result = null;
        ResultSet resultSet = null;
        if (!dbCall.getReturnsResultSet()) {// no result set is expected
            if (dbCall.isCursorOutputProcedure()) {
                result = accessor.executeNoSelect(dbCall, statement, session);
                resultSet = (ResultSet)((CallableStatement)statement).getObject(dbCall.getCursorOutIndex());
            } else {
                accessor.executeDirectNoSelect(statement, dbCall, session);
                result = accessor.buildOutputRow((CallableStatement)statement, dbCall, session);

                //ReadAllQuery may be returning just output params, or they may be executing a DataReadQuery, which also
                //assumes a vector
                if (dbCall.areManyRowsReturned()) {
                    Vector tempResult = new Vector();
                    ((Vector)tempResult).add(result);
                    result = tempResult;
                }
            }
        } else {
            // so specifically in Sybase JConnect 5.5 we must create the result vector before accessing the
            // output params in the case where the user is returning both.  this is a driver limitation
            resultSet = accessor.executeSelect(dbCall, statement, session);
        }
        if (resultSet != null) {
            dbCall.matchFieldOrder(resultSet, accessor, session);

            if (dbCall.isCursorReturned()) {
                dbCall.setStatement(statement);
                dbCall.setResult(resultSet);
                return dbCall;
            }
            result = processResultSet(resultSet, dbCall, statement, accessor, session);

        }
        return result;
    
public java.lang.StringgetAssignmentString()
Used for stored function calls.

        return "= ";
    
public java.lang.StringgetBatchBeginString()
Used for batch writing and sp defs.

        return "";
    
public java.lang.StringgetBatchDelimiterString()
Used for batch writing and sp defs.

        return "; ";
    
public java.lang.StringgetBatchEndString()
Used for batch writing and sp defs.

        return "";
    
public java.util.HashtablegetClassTypes()
Return the class type to database type mapping for the schema framework.

        if (classTypes == null) {
            classTypes = buildClassTypes();
        }
        return classTypes;
    
public java.lang.StringgetConstraintDeletionString()
Used for constraint deletion.

        return " DROP CONSTRAINT ";
    
protected java.lang.StringgetCreateTempTableSqlBodyForTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: May override this method if the platform supports temporary tables. With this method not overridden the sql string for temporary table creation will include a list of database fields extracted from descriptor: getCreateTempTableSqlPrefix() + getTempTableForTable(table).getQualifiedName() + (list of database fields) + getCreateTempTableSqlSuffix(). If this method is overridden its output will be used instead of fields' list: getCreateTempTableSqlPrefix() + getTempTableForTable(table).getQualifiedName() + getCreateTempTableSqlBodyForTable(table) + getCreateTempTableSqlSuffix(). Don't forget to begin it with a space. Example: " LIKE " + table.getQualifiedName();

parameter
DatabaseTable table is original table for which temp table is created.
result
String

         return null;
     
protected java.lang.StringgetCreateTempTableSqlPrefix()
INTERNAL: Override this method if the platform supports temporary tables. This should contain the beginning of sql string for creating temporary table - the sql statement name, for instance: "CREATE GLOBAL TEMPORARY TABLE ". Don't forget to end it with a space.

         throw ValidationException.platformDoesNotOverrideGetCreateTempTableSqlPrefix(Helper.getShortClassName(this));
     
protected java.lang.StringgetCreateTempTableSqlSuffix()
INTERNAL: May override this method if the platform support temporary tables. This should contain the ending of sql string for creating temporary table, for instance: " ON COMMIT DELETE ROWS" Don't forget to begin it with a space.

         return "";
     
public java.lang.StringgetCreateViewString()
Used for view creation.

        return "CREATE VIEW ";
    
public java.lang.StringgetCreationInOutputProcedureToken()
This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.

        return getInOutputProcedureToken();
    
public java.lang.StringgetCreationOutputProcedureToken()
This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.

        return getOutputProcedureToken();
    
public intgetCursorCode()
ADVANCED: Return the code for preparing cursored output parameters in a stored procedure

        return cursorCode;
    
public oracle.toplink.essentials.internal.databaseaccess.FieldTypeDefinitiongetFieldTypeDefinition(java.lang.Class javaClass)
Return the field type object describing this databases platform specific representation of the Java primitive class name.

        return (FieldTypeDefinition)getFieldTypes().get(javaClass);
    
public java.util.HashtablegetFieldTypes()
Return the class type to database type mappings for the schema framework.

        if (fieldTypes == null) {
            fieldTypes = buildFieldTypes();
        }
        return fieldTypes;
    
public java.lang.StringgetFunctionCallHeader()
Used for stored function calls.

        return getProcedureCallHeader() + "? " + getAssignmentString();
    
public java.lang.StringgetInOutputProcedureToken()
This method is used to print the output parameter token when stored procedures are called

        return "IN OUT";
    
public java.lang.StringgetJDBCOuterJoinString()
Returns the JDBC outer join operator for SELECT statements.

        return "{oj ";
    
public intgetJDBCType(oracle.toplink.essentials.internal.helper.DatabaseField field)
Return the JDBC type for the given database field.

        if (field != null) {
            // If the field has a specified JDBC type, use it,
            // otherwise compute the type from the Java class type.
            if (field.getSqlType() != -1) {
                return field.getSqlType();
            } else {
                return getJDBCType(ConversionManager.getObjectClass(field.getType()));
            }
        } else {
            return getJDBCType((Class)null);
        }
    
public intgetJDBCType(java.lang.Class javaType)
Return the JDBC type for the Java type.

        if (javaType == null) {
            return Types.VARCHAR;// Best guess, sometimes we cannot determine type from mapping, this may fail on some drivers, other dont care what type it is.
        } else if (javaType == ClassConstants.STRING) {
            return Types.VARCHAR;
        } else if (javaType == ClassConstants.BIGDECIMAL) {
            return Types.DECIMAL;
        } else if (javaType == ClassConstants.BIGINTEGER) {
            return Types.BIGINT;
        } else if (javaType == ClassConstants.BOOLEAN) {
            return Types.BIT;
        } else if (javaType == ClassConstants.BYTE) {
            return Types.TINYINT;
        } else if (javaType == ClassConstants.CHAR) {
            return Types.CHAR;
        } else if (javaType == ClassConstants.DOUBLE) {
            return Types.DOUBLE;
        } else if (javaType == ClassConstants.FLOAT) {
            return Types.FLOAT;
        } else if (javaType == ClassConstants.INTEGER) {
            return Types.INTEGER;
        } else if (javaType == ClassConstants.LONG) {
            return Types.INTEGER;
        } else if (javaType == ClassConstants.NUMBER) {
            return Types.DECIMAL;
        } else if (javaType == ClassConstants.SHORT ) {
            return Types.SMALLINT;
        } else if (javaType == ClassConstants.CALENDAR ) {
            return Types.TIMESTAMP;
        } else if (javaType == ClassConstants.UTILDATE ) {
            return Types.TIMESTAMP;
        } else if (javaType == ClassConstants.TIME) {
            return Types.TIME;
        } else if (javaType == ClassConstants.SQLDATE) {
            return Types.DATE;
        } else if (javaType == ClassConstants.TIMESTAMP) {
            return Types.TIMESTAMP;
        } else if (javaType == ClassConstants.ABYTE) {
            return Types.LONGVARBINARY;
        } else if (javaType == ClassConstants.APBYTE) {
            return Types.LONGVARBINARY;
        } else if (javaType == ClassConstants.BLOB) {
            return Types.BLOB;
        } else if (javaType == ClassConstants.ACHAR) {
            return Types.LONGVARCHAR;
        } else if (javaType == ClassConstants.APCHAR) {
            return Types.LONGVARCHAR;
        } else if (javaType == ClassConstants.CLOB) {
            return Types.CLOB;
        } else {
            return Types.VARCHAR;// Best guess, sometimes we cannot determine type from mapping, this may fail on some drivers, other dont care what type it is.
        }
    
public java.lang.StringgetJdbcTypeName(int jdbcType)
INTERNAL: Returns the type name corresponding to the jdbc type

        return null;
    
public intgetMaxFieldNameSize()
INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.

        return 50;
    
public intgetMaxForeignKeyNameSize()
INTERNAL: returns the maximum number of characters that can be used in a foreign key name on this platform.

        return getMaxFieldNameSize();
    
public intgetMaxUniqueKeyNameSize()
INTERNAL: returns the maximum number of characters that can be used in a unique key name on this platform.

        return getMaxFieldNameSize();
    
public java.lang.ObjectgetObjectFromResultSet(java.sql.ResultSet resultSet, int columnNumber, int type)
INTERNAL: Get the object from the JDBC Result set. Added to allow other platforms to override.

see
oracle.toplink.essentials.oraclespecific.Oracle9Platform

        return resultSet.getObject(columnNumber);
    
public java.lang.StringgetOutputProcedureToken()
This method is used to print the output parameter token when stored procedures are called

        return "OUT";
    
public java.lang.StringgetProcedureArgumentSetter()
Used for sp calls.

        return " = ";
    
public java.lang.StringgetProcedureArgumentString()
Used for sp defs.

        return "";
    
public java.lang.StringgetProcedureAsString()
Used for stored procedure defs.

        return " AS";
    
public java.lang.StringgetProcedureBeginString()
Used for stored procedure defs.

        return getBatchBeginString();
    
public java.lang.StringgetProcedureCallHeader()
Used for sp calls.

        return "EXECUTE PROCEDURE ";
    
public java.lang.StringgetProcedureCallTail()
Used for sp calls.

        return "";
    
public java.lang.StringgetProcedureEndString()
Used for stored procedure defs.

        return getBatchEndString();
    
public java.lang.StringgetQualifiedSequenceTableName()

        if (getDefaultSequence() instanceof TableSequence) {
            String sequenceTableName = ((TableSequence)getDefaultSequence()).getTableName();
            if (getTableQualifier().equals("")) {
                return sequenceTableName;
            } else {
                return getTableQualifier() + "." + sequenceTableName;
            }
        } else {
            throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "getTableName");
        }
    
public java.lang.StringgetSelectForUpdateNoWaitString()
This syntax does no wait on the lock. (i.e. In Oracle adding NOWAIT to the end will accomplish this)

        return " NOWAIT";
    
public java.lang.StringgetSelectForUpdateOfString()
For fine-grained pessimistic locking the column names can be specified individually.

        return " FOR UPDATE OF ";
    
public java.lang.StringgetSelectForUpdateString()
Most database support a syntax. although don't actually lock the row. Some require the OF some don't like it.

        return " FOR UPDATE OF *";
    
public java.lang.StringgetSequenceCounterFieldName()

        if (getDefaultSequence() instanceof TableSequence) {
            return ((TableSequence)getDefaultSequence()).getCounterFieldName();
        } else {
            throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "getCounterFieldName");
        }
    
public java.lang.StringgetSequenceNameFieldName()

        if (getDefaultSequence() instanceof TableSequence) {
            return ((TableSequence)getDefaultSequence()).getNameFieldName();
        } else {
            throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "getNameFieldName");
        }
    
public intgetSequencePreallocationSize()

        return getDefaultSequence().getPreallocationSize();
    
public java.lang.StringgetSequenceTableName()

        if (getDefaultSequence() instanceof TableSequence) {
            return ((TableSequence)getDefaultSequence()).getTableName();
        } else {
            throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "getTableName");
        }
    
public intgetStatementCacheSize()
The statement cache size for prepare parameterized statements.

        return statementCacheSize;
    
public java.lang.StringgetStoredProcedureParameterPrefix()

        return "";
    
public java.lang.StringgetStoredProcedureTerminationToken()

        return ";";
    
public intgetStringBindingSize()

        return stringBindingSize;
    
public oracle.toplink.essentials.internal.helper.DatabaseTablegetTempTableForTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: May override this method if the platform support temporary tables.

parameter
DatabaseTable table is original table for which temp table is created.
return
DatabaseTable temorary table

         return new DatabaseTable("TL_" + table.getName(), table.getTableQualifier());
     
public intgetTransactionIsolation()
Returns the transaction isolation setting for a connection. Return -1 if it has not been set.

        return transactionIsolation;
    
public booleanisInformixOuterJoin()
Some database require outer joins to be given in the where clause, others require it in the from clause. Informix requires it in the from clause with no ON expression.

        return false;
    
public booleanisNullAllowedInSelectClause()
INTERNAL: Override this if the platform cannot handle NULL in select clause.

        return true;
    
public java.util.HashtablemaximumNumericValues()
Builds a table of maximum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal maximums are dependent upon their precision & Scale

        Hashtable values = new Hashtable();

        values.put(Integer.class, new Integer(Integer.MAX_VALUE));
        values.put(Long.class, new Long(Long.MAX_VALUE));
        values.put(Double.class, new Double(Double.MAX_VALUE));
        values.put(Short.class, new Short(Short.MAX_VALUE));
        values.put(Byte.class, new Byte(Byte.MAX_VALUE));
        values.put(Float.class, new Float(Float.MAX_VALUE));
        values.put(java.math.BigInteger.class, new java.math.BigInteger("999999999999999999999999999999999999999"));
        values.put(java.math.BigDecimal.class, new java.math.BigDecimal("99999999999999999999.9999999999999999999"));
        return values;
    
public java.util.HashtableminimumNumericValues()
Builds a table of minimum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal minimums are dependent upon their precision & Scale

        Hashtable values = new Hashtable();

        values.put(Integer.class, new Integer(Integer.MIN_VALUE));
        values.put(Long.class, new Long(Long.MIN_VALUE));
        values.put(Double.class, new Double(Double.MIN_VALUE));
        values.put(Short.class, new Short(Short.MIN_VALUE));
        values.put(Byte.class, new Byte(Byte.MIN_VALUE));
        values.put(Float.class, new Float(Float.MIN_VALUE));
        values.put(java.math.BigInteger.class, new java.math.BigInteger("-99999999999999999999999999999999999999"));
        values.put(java.math.BigDecimal.class, new java.math.BigDecimal("-9999999999999999999.9999999999999999999"));
        return values;
    
public voidprintFieldIdentityClause(java.io.Writer writer, oracle.toplink.essentials.internal.sessions.AbstractSession session, java.lang.String qualifiedFieldName)
Append the receiver's field 'identity' constraint clause to a writer.

        if (shouldAcquireSequenceValueAfterInsert(session,  qualifiedFieldName)) {
            printFieldIdentityClause(writer);
        }
    
public voidprintFieldIdentityClause(java.io.Writer writer)
Append the receiver's field 'identity' constraint clause to a writer.

        //The default is to do nothing.
    
public voidprintFieldNotNullClause(java.io.Writer writer)
Append the receiver's field 'NOT NULL' constraint clause to a writer.

        try {
            writer.write(" NOT NULL");
        } catch (IOException ioException) {
            throw ValidationException.fileError(ioException);
        }
    
public voidprintFieldNullClause(java.io.Writer writer)
Append the receiver's field 'NULL' constraint clause to a writer.

        // The default is to do nothing
    
public voidprintFieldTypeSize(java.io.Writer writer, oracle.toplink.essentials.tools.schemaframework.FieldDefinition field, oracle.toplink.essentials.internal.databaseaccess.FieldTypeDefinition fieldType, oracle.toplink.essentials.internal.sessions.AbstractSession session, java.lang.String qualifiedFieldName)

        writer.write(fieldType.getName());
        if ((fieldType.isSizeAllowed()) && ((field.getSize() != 0) || (fieldType.isSizeRequired()))) {
            writer.write("(");
            if (field.getSize() == 0) {
                writer.write(new Integer(fieldType.getDefaultSize()).toString());
            } else {
                writer.write(new Integer(field.getSize()).toString());
            }
            if (field.getSubSize() != 0) {
                writer.write(",");
                writer.write(new Integer(field.getSubSize()).toString());
            } else if (fieldType.getDefaultSubSize() != 0) {
                writer.write(",");
                writer.write(new Integer(fieldType.getDefaultSubSize()).toString());
            }
            writer.write(")");
        }
    
public voidprintFieldUnique(java.io.Writer writer, boolean isUnique, oracle.toplink.essentials.internal.sessions.AbstractSession session, java.lang.String qualifiedFieldName)

        if (isUnique) {
            if (supportsPrimaryKeyConstraint()) {
                writer.write(" UNIQUE");
            }
        }
    
public intprintValuelist(int[] theObjects, oracle.toplink.essentials.internal.databaseaccess.DatabaseCall call, java.io.Writer writer)
Added November 7, 2000 JED Prs reference: 24501 Tracker reference: 14111 Print the int array on the writer. Added to handle int[] passed as parameters to named queries Returns the number of objects using binding.

        int nBoundParameters = 0;
        writer.write("(");

        for (int i = 0; i < theObjects.length; i++) {
            nBoundParameters = nBoundParameters + appendParameterInternal(call, writer, new Integer(theObjects[i]));
            if (i < (theObjects.length - 1)) {
                writer.write(", ");
            }
        }

        writer.write(")");
        return nBoundParameters;
    
public intprintValuelist(java.util.Vector theObjects, oracle.toplink.essentials.internal.databaseaccess.DatabaseCall call, java.io.Writer writer)
Returns the number of objects using binding.

        int nBoundParameters = 0;
        Enumeration enumtr = theObjects.elements();
        while (enumtr.hasMoreElements()) {
            nBoundParameters = nBoundParameters + appendParameterInternal(call, writer, enumtr.nextElement());
            if (enumtr.hasMoreElements()) {
                writer.write(", ");
            }
        }
        return nBoundParameters;
    
protected java.lang.ObjectprocessResultSet(java.sql.ResultSet resultSet, oracle.toplink.essentials.internal.databaseaccess.DatabaseCall dbCall, java.sql.PreparedStatement statement, oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession session)

        Object result = null;
        ResultSetMetaData metaData = resultSet.getMetaData();

        session.startOperationProfile(SessionProfiler.ROW_FETCH);
        try {
            if (dbCall.isOneRowReturned()) {
                if (resultSet.next()) {
                    result = accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session);
                    if (resultSet.next()) {
                        // Raise more rows event, some apps may interpret as error or warning.
                        session.getEventManager().moreRowsDetected(dbCall);
                    }
                } else {
                    result = null;
                }
            } else {
                Vector results = new Vector(20);
                while (resultSet.next()) {
                    results.addElement(accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session));
                }
                result = results;
            }
            resultSet.close();// This must be closed incase the statement is cached and not closed.
        } finally {
            session.endOperationProfile(SessionProfiler.ROW_FETCH);
        }
        return result;
    
public voidregisterOutputParameter(java.sql.CallableStatement statement, int index, int jdbcType)
This method is used to register output parameter on Callable Statements for Stored Procedures as each database seems to have a different method.

        statement.registerOutParameter(index, jdbcType);
    
public booleanrequiresNamedPrimaryKeyConstraints()
This is used as some databases create the primary key constraint differently, i.e. Access.

        return false;
    
public booleanrequiresProcedureCallBrackets()
USed for sp calls.

        return true;
    
public booleanrequiresProcedureCallOuputToken()
Used for sp calls. Sybase must print output after output params.

        return false;
    
public booleanrequiresTypeNameToRegisterOutputParameter()
INTERNAL: Indicates whether the version of CallableStatement.registerOutputParameter method that takes type name should be used.

        return false;
    
public voidrollbackTransaction(oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor accessor)
Used for jdbc drivers which do not support autocommit to explicitly rollback a transaction This method is a no-op for databases which implement autocommit as expected.

        if (!supportsAutoCommit()) {
            accessor.getConnection().rollback();
        }
    
protected voidsetClassTypes(java.util.Hashtable classTypes)

        this.classTypes = classTypes;
    
private booleansetComplexParameterValue(oracle.toplink.essentials.internal.sessions.AbstractSession session, java.sql.PreparedStatement statement, int index, java.lang.Object parameter)
Set a complex parameter.

return
true if parameter was successfully set by this method, false otherwise.

        if (parameter == null) {
            // no DatabaseField available
            statement.setNull(index, getJDBCType((Class)null));
        } else if (parameter instanceof DatabaseField) {
            // Substituted null value for the corresponding DatabaseField.
            // Cannot bind null through set object, so we must compute to type.
            int jdbcType = getJDBCType((DatabaseField)parameter);
            statement.setNull(index, jdbcType);
        } else if ((parameter instanceof byte[]) && (usesStreamsForBinding())) {
            ByteArrayInputStream inputStream = new ByteArrayInputStream((byte[])parameter);
            statement.setBinaryStream(index, inputStream, ((byte[])parameter).length);
        } else if ((parameter instanceof String) && usesStringBinding() && (((String)parameter).length() > getStringBindingSize())) {
            CharArrayReader reader = new CharArrayReader(((String)parameter).toCharArray());
            statement.setCharacterStream(index, reader, ((String)parameter).length());
        } else if (parameter instanceof BindCallCustomParameter) {
            ((BindCallCustomParameter)(parameter)).set(this, statement, index, session);
        } else {
            return false;
        }
        return true;
    
public voidsetCursorCode(int cursorCode)
ADVANCED: Set the code for preparing cursored output parameters in a stored procedure

        this.cursorCode = cursorCode;
    
protected voidsetFieldTypes(java.util.Hashtable theFieldTypes)

        fieldTypes = theFieldTypes;
    
public voidsetParameterValueInDatabaseCall(java.lang.Object parameter, java.sql.PreparedStatement statement, int index, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL Note that index (not index+1) is used in statement.setObject(index, parameter) Binding starts with a 1 not 0, so make sure that index > 0.

        // 2.0p22: Added the following conversion before binding into prepared statement
        parameter = convertToDatabaseType(parameter);
        if (! setComplexParameterValue(session, statement, index, parameter)) {
            setPrimitiveParameterValue(statement, index, parameter);
        }
    
public voidsetParameterValueInDatabaseCall(java.util.Vector parameters, java.sql.PreparedStatement statement, int parameterIndex, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL Used by SQLCall.prepareStatement(..) Note that parameterIndex corresponds to parameters vector and index corresponds to statement: statement.setObject(parameterIndex + 1, parameters.elementAt(parameterIndex)) Therefore parameterIndex may be 0.

        setParameterValueInDatabaseCall(parameters, statement, parameterIndex, parameterIndex + 1, session);
    
public voidsetParameterValueInDatabaseCall(java.util.Vector parameters, java.sql.PreparedStatement statement, int parameterIndex, int index, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL Used by StoredProcedureCall.prepareStatement(..) Note that parameterIndex corresponds to parameters vector and index corresponds to statement: statement.setObject(index, parameters.elementAt(parameterIndex)) Therefore parameterIndex may be 0, but index > 0.

        setParameterValueInDatabaseCall(parameters.elementAt(parameterIndex), statement, index, session);
    
protected voidsetPrimitiveParameterValue(java.sql.PreparedStatement statement, int index, java.lang.Object parameter)
Set a primitive parameter. Database platforms that need customised behavior would override this method

        statement.setObject(index, parameter);
    
public voidsetSequenceCounterFieldName(java.lang.String name)

        if (getDefaultSequence() instanceof TableSequence) {
            ((TableSequence)getDefaultSequence()).setCounterFieldName(name);
        } else {
            if (!name.equals((new TableSequence()).getCounterFieldName())) {
                ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "setCounterFieldName");
            }
        }
    
public voidsetSequenceNameFieldName(java.lang.String name)

        if (getDefaultSequence() instanceof TableSequence) {
            ((TableSequence)getDefaultSequence()).setNameFieldName(name);
        } else {
            if (!name.equals((new TableSequence()).getNameFieldName())) {
                throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "setNameFieldName");
            }
        }
    
public voidsetSequenceTableName(java.lang.String name)

        if (getDefaultSequence() instanceof TableSequence) {
            ((TableSequence)getDefaultSequence()).setTableName(name);
        } else {
            if (!name.equals((new TableSequence()).getTableName())) {
                throw ValidationException.wrongSequenceType(Helper.getShortClassName(getDefaultSequence()), "setTableName");
            }
        }
    
public voidsetShouldBindAllParameters(boolean shouldBindAllParameters)
Bind all arguments to any SQL statement.

        this.shouldBindAllParameters = shouldBindAllParameters;
    
public voidsetShouldCacheAllStatements(boolean shouldCacheAllStatements)
Cache all prepared statements, this requires full parameter binding as well.

        this.shouldCacheAllStatements = shouldCacheAllStatements;
    
public voidsetShouldForceFieldNamesToUpperCase(boolean shouldForceFieldNamesToUpperCase)
Can be used if the app expects upper case but the database is not return consistent case, i.e. different databases.

        this.shouldForceFieldNamesToUpperCase = shouldForceFieldNamesToUpperCase;
    
public static voidsetShouldIgnoreCaseOnFieldComparisons(boolean newShouldIgnoreCaseOnFieldComparisons)
Allow for case in field names to be ignored as some databases are not case sensitive and when using custom this can be an issue.

        shouldIgnoreCaseOnFieldComparisons = newShouldIgnoreCaseOnFieldComparisons;
    
public voidsetShouldOptimizeDataConversion(boolean value)
PUBLIC: Set if our driver level data conversion optimization is enabled. This can be disabled as some drivers perform data conversion themselves incorrectly.

        this.shouldOptimizeDataConversion = value;
    
public voidsetShouldTrimStrings(boolean aBoolean)

        shouldTrimStrings = aBoolean;
    
public voidsetStatementCacheSize(int statementCacheSize)
The statement cache size for prepare parameterized statements.

        this.statementCacheSize = statementCacheSize;
    
public voidsetStringBindingSize(int aSize)

        stringBindingSize = aSize;
    
public voidsetSupportsAutoCommit(boolean supportsAutoCommit)
supportsAutoCommit can be set to false for JDBC drivers which do not support autocommit

return
boolean

        this.supportsAutoCommit = supportsAutoCommit;
    
public voidsetTransactionIsolation(int isolationLevel)
Set the transaction isolation setting for a connection.

        transactionIsolation = isolationLevel;
    
public voidsetUsesByteArrayBinding(boolean usesByteArrayBinding)

        this.usesByteArrayBinding = usesByteArrayBinding;
    
public voidsetUsesNativeSQL(boolean usesNativeSQL)

        this.usesNativeSQL = usesNativeSQL;
    
public voidsetUsesStreamsForBinding(boolean usesStreamsForBinding)

        this.usesStreamsForBinding = usesStreamsForBinding;
    
public voidsetUsesStringBinding(boolean aBool)

        usesStringBinding = aBool;
    
public booleanshouldAcquireSequenceValueAfterInsert(oracle.toplink.essentials.internal.sessions.AbstractSession session, java.lang.String qualifiedFieldName)

        if (!supportsNativeSequenceNumbers() || !shouldNativeSequenceAcquireValueAfterInsert()) {
            return false;
        }
        if ((session.getSequencing() == null) || (session.getSequencing().whenShouldAcquireValueForAll() == Sequencing.BEFORE_INSERT)) {
            return false;
        }

        boolean shouldAcquireSequenceValueAfterInsert = false;
        DatabaseField field = new DatabaseField(qualifiedFieldName);
        Iterator descriptors = session.getDescriptors().values().iterator();
        while (descriptors.hasNext()) {
            ClassDescriptor descriptor = (ClassDescriptor)descriptors.next();
            if (!descriptor.usesSequenceNumbers()) {
                continue;
            }
            if (descriptor.getSequenceNumberField().equals(field)) {
                String seqName = descriptor.getSequenceNumberName();
                Sequence sequence = getSequence(seqName);
                shouldAcquireSequenceValueAfterInsert = sequence.shouldAcquireValueAfterInsert();
                break;
            }
        }
        return shouldAcquireSequenceValueAfterInsert;
    
public booleanshouldAlwaysUseTempStorageForModifyAll()
INTERNAL: That method affects UpdateAllQuery and DeleteAllQuery execution. In case it returns false modify all queries would attempt to proceed without using temporary storage if it is possible. In case it returns true modify all queries would use temporary storage unless each modify statement doesn't reference any other tables. May need to override this method if the platform can't handle the sql generated for modify all queries without using temporary storage.

        return false;
    
public booleanshouldBindAllParameters()
Bind all arguments to any SQL statement.

        return shouldBindAllParameters;
    
public booleanshouldBindLiterals()
INTERNAL Allows platform to choose whether to bind literals in DatabaseCalls or not.

        return true;
    
public booleanshouldCacheAllStatements()
Cache all prepared statements, this requires full parameter binding as well.

        return shouldCacheAllStatements;
    
public booleanshouldForceFieldNamesToUpperCase()
Can be used if the app expects upper case but the database is not return consistent case, i.e. different databases.

        return shouldForceFieldNamesToUpperCase;
    
public static booleanshouldIgnoreCaseOnFieldComparisons()
Allow for case in field names to be ignored as some databases are not case sensitive and when using custom this can be an issue.

        return shouldIgnoreCaseOnFieldComparisons;
    
public booleanshouldIgnoreException(java.sql.SQLException exception)
Allow for the platform to ignore exceptions. This is required for DB2 which throws no-data modified as an exception.

        // By default nothing is ignored.
        return false;
    
public booleanshouldNativeSequenceAcquireValueAfterInsert()
INTERNAL: Indicates whether NativeSequence should retrieve sequence value after the object has been inserted into the db This method is to be used *ONLY* by sequencing classes

        return false;
    
public booleanshouldNativeSequenceUseTransaction()
INTERNAL Indicates whether a separate transaction is required for NativeSequence. This method is to be used *ONLY* by sequencing classes

        return false;
    
public booleanshouldOptimizeDataConversion()
Return if our driver level data conversion optimization is enabled. This can be disabled as some drivers perform data conversion themselves incorrectly.

        return shouldOptimizeDataConversion;
    
public booleanshouldPrintConstraintNameAfter()
Some Platforms want the constraint name after the constraint definition.

        return false;
    
public booleanshouldPrintInOutputTokenBeforeType()
This is required in the construction of the stored procedures with output parameters

        return true;
    
public booleanshouldPrintOuterJoinInWhereClause()
Some database require outer joins to be given in the where clause, others require it in the from clause.

        return false;
    
public booleanshouldPrintOutputTokenAtStart()
This is required in the construction of the stored procedures with output parameters

        return false;
    
public booleanshouldPrintOutputTokenBeforeType()
This is required in the construction of the stored procedures with output parameters

        return true;
    
protected booleanshouldTempTableSpecifyPrimaryKeys()
INTERNAL: Indicates whether temporary table can specify primary keys (some platforms don't allow that). Used by writeCreateTempTableSql method.

        return true;
    
public booleanshouldTrimStrings()

        return shouldTrimStrings;
    
public booleanshouldUseJDBCOuterJoinSyntax()
JDBC defines and outer join syntax, many drivers do not support this. So we normally avoid it.

        return true;
    
public booleansupportsAutoCommit()
supportsAutoCommit must sometimes be set to false for JDBC drivers which do not support autocommit. Used to determine how to handle transactions properly.

        return supportsAutoCommit;
    
public booleansupportsForeignKeyConstraints()

        return true;
    
public booleansupportsGlobalTempTables()
INTERNAL: Indicates whether the platform supports global temporary tables. "Global" means that an attempt to create temporary table with the same name for the second time results in exception. TopLink attempts to create global temporary table in the beginning of UpdateAllQuery, execution and assumes that it already exists in case SQLException results. In the end of UpdateAllQuery execution all rows are removed from the temporary table - it is necessary in case the same temporary table will be used by another UpdateAllQuery in the same transaction. Override this method if the platform supports global temporary tables. Note that this method is ignored in case supportsLocalTempTables() returns true.

         return false;
     
public booleansupportsLocalTempTables()
INTERNAL: Indicates whether the platform supports local temporary tables. "Local" means that several threads may create temporary tables with the same name. Local temporary table is created in the beginning of UpdateAllQuery execution and dropped in the end of it. Override this method if the platform supports local temporary tables.

         return false;
     
public booleansupportsNativeSequenceNumbers()

        return false;
    
public booleansupportsPrimaryKeyConstraint()

        return true;
    
public booleansupportsStoredFunctions()

        return false;
    
public booleansupportsTempTables()
INTERNAL: Indicates whether the platform supports temporary tables. Temporary tables may be used by UpdateAllQueries: though attempt is always made to perform UpdateAll without using temporary storage there are some scenarios that can't be fulfilled without it. Don't override this method. If the platform support temorary tables then override either supportsLocalTempTables() or supportsGlobalTempTables() method.

         return supportsLocalTempTables() || supportsGlobalTempTables();
     
public booleansupportsUniqueKeyConstraints()

        return true;
    
public booleanusesByteArrayBinding()

        return usesByteArrayBinding;
    
public booleanusesNativeSQL()

        return usesNativeSQL;
    
public booleanusesSequenceTable()

        return getDefaultSequence() instanceof TableSequence;
    
public booleanusesStreamsForBinding()

        return usesStreamsForBinding;
    
public booleanusesStringBinding()

        return usesStringBinding;
    
protected static voidwriteAutoAssignmentSetClause(java.io.Writer writer, java.lang.String tableName1, java.lang.String tableName2, java.util.Collection fields)
INTERNAL: helper method, don't override.

        writer.write(" SET ");
        writeFieldsAutoClause(writer, tableName1, tableName2, fields, ", ");
    
protected static voidwriteAutoJoinWhereClause(java.io.Writer writer, java.lang.String tableName1, java.lang.String tableName2, java.util.Collection pkFields)
INTERNAL: helper method, don't override.

        writer.write(" WHERE ");
        writeFieldsAutoClause(writer, tableName1, tableName2, pkFields, " AND ");
    
public voidwriteCleanUpTempTableSql(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: Don't override this method. Write an sql string for clean up of the temporary table. Drop a local temp table or delete all from a global temp table (so that it's ready to be used again in the same transaction). Precondition: supportsTempTables() == true.

parameter
Writer writer for writing the sql
parameter
DatabaseTable table is original table for which temp table is created.

        if(supportsLocalTempTables()) {
            writer.write("DROP TABLE ");
        } else {
            // supportsGlobalTempTables() == true
            writer.write("DELETE FROM ");
        }
        writer.write(getTempTableForTable(table).getQualifiedName());
    
public voidwriteCreateTempTableSql(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseTable table, oracle.toplink.essentials.internal.sessions.AbstractSession session, java.util.Collection pkFields, java.util.Collection usedFields, java.util.Collection allFields)
INTERNAL: Don't override this method. Write an sql string for creation of the temporary table. Note that in case of local temp table support it's possible to limit the fields in the temp table to those needed for the operation it supports (usedFields) - the temp table will be dropped in the end of query execution. Alternatively, in global temp table case the table with a given name is created just once and will be potentially used by various operations with various sets of used fields, therefore global temp table should contain all mapped fields (allFields). Precondition: supportsTempTables() == true. Precondition: pkFields contained in usedFields contained in allFields

parameter
Writer writer for writing the sql
parameter
DatabaseTable table is original table for which temp table is created.
parameter
AbstractSession session.
parameter
Collection pkFields - primary key fields for the original table.
parameter
Collection usedFields - fields that will be used by operation for which temp table is created.
parameter
Collection allFields - all mapped fields for the original table.

        String body = getCreateTempTableSqlBodyForTable(table);
        if(body == null) {
            TableDefinition tableDef = new TableDefinition();
            Collection fields;
            if(supportsLocalTempTables()) {
                fields = usedFields;
            } else {
                // supportsGlobalTempTables() == true
                fields = allFields;
            }
            Iterator itFields = fields.iterator();
            while(itFields.hasNext()) {
                DatabaseField field = (DatabaseField)itFields.next();
                FieldDefinition fieldDef;
                //bug3307, should use columnDefinition if it was defined.
                if(field.getColumnDefinition().length() == 0){
                   fieldDef = new FieldDefinition(field.getName(), ConversionManager.getObjectClass(field.getType()));
                }else{
                   fieldDef = new FieldDefinition(field.getName(), field.getColumnDefinition());
                }
                if(pkFields.contains(field) && shouldTempTableSpecifyPrimaryKeys()) {
                    fieldDef.setIsPrimaryKey(true);
                }
                tableDef.addField(fieldDef);
            }            
            tableDef.setCreationPrefix(getCreateTempTableSqlPrefix());
            tableDef.setName(getTempTableForTable(table).getQualifiedName());
            tableDef.setCreationSuffix(getCreateTempTableSqlSuffix());
            tableDef.buildCreationWriter(session, writer);
        } else {
            writer.write(getCreateTempTableSqlPrefix());
            writer.write(getTempTableForTable(table).getQualifiedName());
            writer.write(body);
            writer.write(getCreateTempTableSqlSuffix());
        }
    
public voidwriteDeleteFromTargetTableUsingTempTableSql(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseTable table, oracle.toplink.essentials.internal.helper.DatabaseTable targetTable, java.util.Collection pkFields, java.util.Collection targetPkFields)
INTERNAL: Write an sql string for deletion from target table using temporary table. At this point temporary table should contains pks for the rows that should be deleted from target table. Temporary tables are not required for DeleteAllQuery, however will be used if shouldAlwaysUseTempStorageForModifyAll()==true May need to override this method in case it generates sql that doesn't work on the platform. Precondition: supportsTempTables() == true.

parameter
Writer writer for writing the sql
parameter
DatabaseTable table is original table for which temp table is created.
parameter
DatabaseTable targetTable is a table from which to delete.
parameter
Collection pkFields - primary key fields for the original table.
parameter
Collection targetPkFields - primary key fields for the target table.
parameter
Collection assignedFields - fields to be assigned a new value.

        writer.write("DELETE FROM ");
        String targetTableName = targetTable.getQualifiedName();
        writer.write(targetTableName);
        writer.write(" WHERE EXISTS(SELECT ");
        writer.write(((DatabaseField)pkFields.iterator().next()).getName());
        writer.write(" FROM ");
        String tempTableName = getTempTableForTable(table).getQualifiedName();
        writer.write(tempTableName);
        writeJoinWhereClause(writer, null, targetTableName, pkFields, targetPkFields);
        writer.write(")");
    
protected static voidwriteFields(java.io.Writer writer, java.lang.String tableName1, java.lang.String tableName2, java.util.Collection fields1, java.util.Collection fields2, java.lang.String separator)
INTERNAL: helper method, don't override.

        boolean isFirst = true;
        Iterator itFields1 = fields1.iterator();
        Iterator itFields2 = fields2.iterator();
        while(itFields1.hasNext()) {
            if(isFirst) {
                isFirst = false;
            } else {
                writer.write(separator);
            }
            if(tableName1 != null) {
                writer.write(tableName1);
                writer.write(".");
            }
            String fieldName1 = ((DatabaseField)itFields1.next()).getName();
            writer.write(fieldName1);
            writer.write(" = ");
            if(tableName2 != null) {
                writer.write(tableName2);
                writer.write(".");
            }
            String fieldName2 = ((DatabaseField)itFields2.next()).getName();
            writer.write(fieldName2);
        }
    
protected static voidwriteFieldsAutoClause(java.io.Writer writer, java.lang.String tableName1, java.lang.String tableName2, java.util.Collection fields, java.lang.String separator)
INTERNAL: helper method, don't override.

        writeFields(writer, tableName1, tableName2, fields, fields, separator);
    
protected static voidwriteFieldsList(java.io.Writer writer, java.util.Collection fields)
INTERNAL: helper method, don't override.

        boolean isFirst = true;
        Iterator itFields = fields.iterator();
        while(itFields.hasNext()) {
            if(isFirst) {
                isFirst = false;
            } else {
                writer.write(", ");
            }
            DatabaseField field = (DatabaseField)itFields.next();
            writer.write(field.getName());
        }
    
public voidwriteInsertIntoTableSql(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseTable table, java.util.Collection usedFields)
INTERNAL: May need to override this method if the platform supports temporary tables and the generated sql doesn't work. Write an sql string for insertion into the temporary table. Precondition: supportsTempTables() == true.

parameter
Writer writer for writing the sql
parameter
DatabaseTable table is original table for which temp table is created.
parameter
Collection usedFields - fields that will be used by operation for which temp table is created.

        writer.write("INSERT INTO ");
        writer.write(getTempTableForTable(table).getQualifiedName());

        writer.write(" (");        
        writeFieldsList(writer, usedFields);
        writer.write(") ");
    
protected static voidwriteJoinWhereClause(java.io.Writer writer, java.lang.String tableName1, java.lang.String tableName2, java.util.Collection pkFields1, java.util.Collection pkFields2)
INTERNAL: helper method, don't override.

        writer.write(" WHERE ");
        writeFields(writer, tableName1, tableName2, pkFields1, pkFields2, " AND ");
    
public voidwriteLOB(oracle.toplink.essentials.internal.helper.DatabaseField field, java.lang.Object value, java.sql.ResultSet resultSet, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL: Write LOB value - only on Oracle8 and up

        // used by Oracle8Platform
    
public voidwriteParameterMarker(java.io.Writer writer, oracle.toplink.essentials.internal.expressions.ParameterExpression expression)

        writer.write("?");
    
public voidwriteUpdateOriginalFromTempTableSql(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseTable table, java.util.Collection pkFields, java.util.Collection assignedFields)
INTERNAL: May need to override this method if the platform supports temporary tables and the generated sql doesn't work. Write an sql string for updating the original table from the temporary table. Precondition: supportsTempTables() == true. Precondition: pkFields and assignFields don't intersect.

parameter
Writer writer for writing the sql
parameter
DatabaseTable table is original table for which temp table is created.
parameter
Collection pkFields - primary key fields for the original table.
parameter
Collection assignedFields - fields to be assigned a new value.

        writer.write("UPDATE ");
        String tableName = table.getQualifiedName();
        writer.write(tableName);
        writer.write(" SET (");
        writeFieldsList(writer, assignedFields);
        writer.write(") = (SELECT ");        
        writeFieldsList(writer, assignedFields);
        writer.write(" FROM ");
        String tempTableName = getTempTableForTable(table).getQualifiedName();
        writer.write(tempTableName);
        writeAutoJoinWhereClause(writer, null, tableName, pkFields);
        writer.write(") WHERE EXISTS(SELECT ");
        writer.write(((DatabaseField)pkFields.iterator().next()).getName());
        writer.write(" FROM ");
        writer.write(tempTableName);
        writeAutoJoinWhereClause(writer, null, tableName, pkFields);
        writer.write(")");