FileDocCategorySizeDatePackage
InformixPlatform.javaAPI DocGlassfish v2 API12701Tue May 22 16:54:48 BST 2007oracle.toplink.essentials.platform.database

InformixPlatform

public class InformixPlatform extends DatabasePlatform

Purpose: Provides Informix specific behaviour.

Responsibilities:

  • Types for schema creation.
  • Native sequencing using @@SERIAL.
since
TOPLink/Java 1.0.1

Fields Summary
Constructors Summary
Methods Summary
protected voidappendCalendar(java.util.Calendar calendar, java.io.Writer writer)
INTERNAL: Answer a platform correct string representation of a Calendar, suitable for SQL generation. The date is printed in the ODBC platform independent format {d'YYYY-MM-DD'}.

        if (usesNativeSQL()) {
            appendInformixCalendar(calendar, writer);
        } else {
            super.appendCalendar(calendar, writer);
        }
    
protected voidappendDate(java.sql.Date date, java.io.Writer writer)
INTERNAL: Answer a platform correct string representation of a Date, suitable for SQL generation. Native format: 'yyyy-mm-dd

        if (usesNativeSQL()) {
            writer.write("'");
            writer.write(Helper.printDate(date));
            writer.write("'");
        } else {
            super.appendDate(date, writer);
        }
    
protected voidappendInformixCalendar(java.util.Calendar calendar, java.io.Writer writer)
INTERNAL: Write a timestamp in Informix specific format ( yyyy-mm-dd hh:mm:ss.fff)

        writer.write("'");
        writer.write(Helper.printCalendar(calendar));
        writer.write("'");
    
protected voidappendInformixTimestamp(java.sql.Timestamp timestamp, java.io.Writer writer)
INTERNAL: Write a timestamp in Informix specific format (yyyy-mm-dd hh:mm:ss.fff).

        writer.write("'");
        writer.write(Helper.printTimestampWithoutNanos(timestamp));
        writer.write('.");

        // Must truncate the nanos to three decimal places,
        // it is actually a complex algorithm...
        String nanoString = Integer.toString(timestamp.getNanos());
        int numberOfZeros = 0;
        for (int num = Math.min(9 - nanoString.length(), 3); num > 0; num--) {
            writer.write('0");
            numberOfZeros++;
        }
        if ((nanoString.length() + numberOfZeros) > 3) {
            nanoString = nanoString.substring(0, (3 - numberOfZeros));
        }
        writer.write(nanoString);
        writer.write("'");
    
protected voidappendTime(java.sql.Time time, java.io.Writer writer)
INTERNAL: 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'}.

        if (usesNativeSQL()) {
            writer.write("'");
            writer.write(Helper.printTime(time));
            writer.write("'");
        } else {
            super.appendTime(time, writer);
        }
    
protected voidappendTimestamp(java.sql.Timestamp timestamp, java.io.Writer writer)
INTERNAL: Answer a platform correct string representation of a Timestamp, suitable for SQL generation. The date is printed in the ODBC platform independent format {d'YYYY-MM-DD'}.

        if (usesNativeSQL()) {
            appendInformixTimestamp(timestamp, writer);
        } else {
            super.appendTimestamp(timestamp, writer);
        }
    
protected java.util.HashtablebuildFieldTypes()

        Hashtable fieldTypeMapping;

        fieldTypeMapping = new Hashtable();
        fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("SMALLINT default 0", false));

        fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("INTEGER", false));
        fieldTypeMapping.put(Long.class, new FieldTypeDefinition("NUMERIC", 19));
        fieldTypeMapping.put(Float.class, new FieldTypeDefinition("FLOAT(16)", false));
        fieldTypeMapping.put(Double.class, new FieldTypeDefinition("FLOAT(32)", false));
        fieldTypeMapping.put(Short.class, new FieldTypeDefinition("SMALLINT", false));
        fieldTypeMapping.put(Byte.class, new FieldTypeDefinition("SMALLINT", false));
        fieldTypeMapping.put(java.math.BigInteger.class, new FieldTypeDefinition("DECIMAL", 32));
        fieldTypeMapping.put(java.math.BigDecimal.class, new FieldTypeDefinition("DECIMAL", 32).setLimits(32, -19, 19));
        fieldTypeMapping.put(Number.class, new FieldTypeDefinition("DECIMAL", 32).setLimits(32, -19, 19));

        fieldTypeMapping.put(String.class, new FieldTypeDefinition("VARCHAR", 255));
        fieldTypeMapping.put(Character.class, new FieldTypeDefinition("CHAR", 1));
        
        fieldTypeMapping.put(Byte[].class, new FieldTypeDefinition("BYTE", false));
        fieldTypeMapping.put(Character[].class, new FieldTypeDefinition("TEXT", false));
        fieldTypeMapping.put(byte[].class, new FieldTypeDefinition("BYTE", false));
        fieldTypeMapping.put(char[].class, new FieldTypeDefinition("TEXT", false));
        fieldTypeMapping.put(java.sql.Blob.class, new FieldTypeDefinition("BYTE", false));
        fieldTypeMapping.put(java.sql.Clob.class, new FieldTypeDefinition("TEXT", false));        

        fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE", false));
        fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("DATETIME HOUR TO SECOND", false));
        fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("DATETIME YEAR TO FRACTION(5)", false));

        return fieldTypeMapping;
    
public oracle.toplink.essentials.queryframework.ValueReadQuerybuildSelectQueryForNativeSequence()
INTERNAL: Build the identity query for native sequencing.

        ValueReadQuery selectQuery = new ValueReadQuery();
        StringWriter writer = new StringWriter();
        writer.write("SELECT DISTINCT(DBINFO('sqlca.sqlerrd1')) FROM systables");
        selectQuery.setSQLString(writer.toString());
        return selectQuery;
    
public intgetMaxFieldNameSize()
INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.

        return 18;
    
public java.lang.StringgetSelectForUpdateString()
INTERNAL: Informix seems to like this syntax instead of the OF * syntax.

        return " FOR UPDATE";
    
public booleanisInformix()

        return true;
    
public booleanisInformixOuterJoin()
INTERNAL: 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 true;
    
public java.util.HashtablemaximumNumericValues()
INTERNAL: 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)Float.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("99999999999999999999999999999999999999"));
        values.put(java.math.BigDecimal.class, new java.math.BigDecimal("9999999999999999999.9999999999999999999"));
        return values;
    
public java.util.HashtableminimumNumericValues()
INTERNAL: 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)1.4012984643247149E-44));// The double values are weird. They lose precision at E-45
        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)
INTERNAL: Append the receiver's field serial constraint clause to a writer.

        try {
            writer.write(" SERIAL");
        } catch (IOException ioException) {
            throw ValidationException.fileError(ioException);
        }
    
public booleanrequiresProcedureCallBrackets()
INTERNAL: USed for sp calls.

        return false;
    
public booleanshouldNativeSequenceAcquireValueAfterInsert()
INTERNAL: If native sequencing is being used on Informix then the values must be retrieved after the insert. This method is to be used *ONLY* by sequencing classes

        return true;
    
public booleanshouldPrintConstraintNameAfter()
INTERNAL: Some Platforms want the constraint name after the constraint definition.

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

        return false;
    
public booleansupportsNativeSequenceNumbers()
INTERNAL: Return true if the receiver uses host sequence numbers, generated on the database. Informix does this through SERIAL field types.

        return true;