Search in sources :

Example 1 with FieldTypeDefinition

use of org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition in project teiid by teiid.

the class TeiidPlatform method buildFieldTypes.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Hashtable buildFieldTypes() {
    Hashtable fieldTypeMapping = super.buildFieldTypes();
    fieldTypeMapping.put(byte[].class, new FieldTypeDefinition("varbinary", false));
    fieldTypeMapping.put(Character.class, new FieldTypeDefinition("char", false));
    fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("boolean", false));
    fieldTypeMapping.put(Byte.class, new FieldTypeDefinition("tinyint", false));
    fieldTypeMapping.put(Short.class, new FieldTypeDefinition("smallint", false));
    fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("integer", false));
    fieldTypeMapping.put(Long.class, new FieldTypeDefinition("long", false));
    fieldTypeMapping.put(BigInteger.class, new FieldTypeDefinition("biginteger", false));
    fieldTypeMapping.put(Float.class, new FieldTypeDefinition("float", false));
    fieldTypeMapping.put(Double.class, new FieldTypeDefinition("double", false));
    fieldTypeMapping.put(BigDecimal.class, new FieldTypeDefinition("bigdecimal", false));
    fieldTypeMapping.put(Date.class, new FieldTypeDefinition("date", false));
    fieldTypeMapping.put(Time.class, new FieldTypeDefinition("time", false));
    fieldTypeMapping.put(Timestamp.class, new FieldTypeDefinition("timestamp", false));
    fieldTypeMapping.put(Object.class, new FieldTypeDefinition("object", false));
    fieldTypeMapping.put(Blob.class, new FieldTypeDefinition("blob", false));
    fieldTypeMapping.put(Clob.class, new FieldTypeDefinition("clob", false));
    fieldTypeMapping.put(SQLXML.class, new FieldTypeDefinition("xml", false));
    return fieldTypeMapping;
}
Also used : FieldTypeDefinition(org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition) Hashtable(java.util.Hashtable)

Example 2 with FieldTypeDefinition

use of org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition in project eclipselink by eclipse-ee4j.

the class HSQLPlatform method buildFieldTypes.

@Override
protected Hashtable<Class<?>, FieldTypeDefinition> buildFieldTypes() {
    Hashtable<Class<?>, FieldTypeDefinition> fieldTypeMapping = super.buildFieldTypes();
    fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("BOOLEAN", false));
    fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("INTEGER", false));
    fieldTypeMapping.put(Long.class, new FieldTypeDefinition("BIGINT", false));
    fieldTypeMapping.put(Float.class, new FieldTypeDefinition("REAL", false));
    fieldTypeMapping.put(Double.class, new FieldTypeDefinition("REAL", 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("BIGINT", false));
    fieldTypeMapping.put(java.math.BigDecimal.class, new FieldTypeDefinition("NUMERIC", 38).setLimits(38, -19, 19));
    fieldTypeMapping.put(Number.class, new FieldTypeDefinition("NUMERIC", 38).setLimits(38, -19, 19));
    fieldTypeMapping.put(Byte[].class, new FieldTypeDefinition("LONGVARBINARY", false));
    fieldTypeMapping.put(Character[].class, new FieldTypeDefinition("LONGVARCHAR", false));
    fieldTypeMapping.put(byte[].class, new FieldTypeDefinition("LONGVARBINARY", false));
    fieldTypeMapping.put(char[].class, new FieldTypeDefinition("LONGVARCHAR", false));
    // 319592: HSQL 2.0.0 requires VARCHAR length specified
    fieldTypeMapping.put(String.class, new FieldTypeDefinition("VARCHAR", DEFAULT_VARCHAR_SIZE));
    fieldTypeMapping.put(java.sql.Blob.class, new FieldTypeDefinition("LONGVARBINARY", false));
    fieldTypeMapping.put(java.sql.Clob.class, new FieldTypeDefinition("LONGVARCHAR", false));
    fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE", false));
    fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMP", false));
    fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("TIME", false));
    fieldTypeMapping.put(java.util.Calendar.class, new FieldTypeDefinition("TIMESTAMP", false));
    fieldTypeMapping.put(java.util.Date.class, new FieldTypeDefinition("TIMESTAMP", false));
    return fieldTypeMapping;
}
Also used : java.util(java.util) FieldTypeDefinition(org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition)

Example 3 with FieldTypeDefinition

use of org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition in project eclipselink by eclipse-ee4j.

the class MaxDBPlatform method buildFieldTypes.

@Override
protected Hashtable<Class<?>, FieldTypeDefinition> buildFieldTypes() {
    final Hashtable<Class<?>, FieldTypeDefinition> fieldTypeMapping = new Hashtable<>();
    // TODO boolean
    fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("SMALLINT", false));
    fieldTypeMapping.put(Number.class, new FieldTypeDefinition("DOUBLE PRECISION", false));
    fieldTypeMapping.put(Short.class, new FieldTypeDefinition("SMALLINT", false));
    fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("INTEGER", false));
    fieldTypeMapping.put(Long.class, new FieldTypeDefinition("FIXED", 19));
    fieldTypeMapping.put(Float.class, new FieldTypeDefinition("FLOAT", false));
    fieldTypeMapping.put(Double.class, new FieldTypeDefinition("DOUBLE PRECISION", false));
    fieldTypeMapping.put(BigInteger.class, new FieldTypeDefinition("FIXED", 19));
    fieldTypeMapping.put(BigDecimal.class, new FieldTypeDefinition("FIXED", 38));
    fieldTypeMapping.put(Character.class, new FieldTypeDefinition("CHAR", 1, "UNICODE"));
    fieldTypeMapping.put(Character[].class, new FieldTypeDefinition("VARCHAR", 255, "UNICODE"));
    fieldTypeMapping.put(char[].class, new FieldTypeDefinition("VARCHAR", 255, "UNICODE"));
    fieldTypeMapping.put(String.class, new FieldTypeDefinition("VARCHAR", 255, "UNICODE"));
    // can't be mapped to CHAR(1) BYTE as byte in java is signed
    fieldTypeMapping.put(Byte.class, new FieldTypeDefinition("SMALLINT", false));
    fieldTypeMapping.put(Byte[].class, FIELD_TYPE_DEFINITION_BLOB);
    fieldTypeMapping.put(byte[].class, FIELD_TYPE_DEFINITION_BLOB);
    fieldTypeMapping.put(Blob.class, FIELD_TYPE_DEFINITION_BLOB);
    fieldTypeMapping.put(Clob.class, FIELD_TYPE_DEFINITION_CLOB);
    fieldTypeMapping.put(Date.class, new FieldTypeDefinition("DATE", false));
    fieldTypeMapping.put(Time.class, new FieldTypeDefinition("TIME", false));
    fieldTypeMapping.put(Timestamp.class, new FieldTypeDefinition("TIMESTAMP", false));
    return fieldTypeMapping;
}
Also used : FieldTypeDefinition(org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition) Hashtable(java.util.Hashtable)

Example 4 with FieldTypeDefinition

use of org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition in project eclipselink by eclipse-ee4j.

the class StoredProcedureDefinition method printArgument.

/**
 * Print the argument and its type.
 * @param argument Stored procedure argument.
 * @param writer   Target writer where to write argument string.
 * @param session  Current session context.
 * @throws IOException When any IO problem occurs.
 */
protected void printArgument(final FieldDefinition argument, final Writer writer, final AbstractSession session) throws IOException {
    final DatabasePlatform platform = session.getPlatform();
    final FieldTypeDefinition fieldType = getFieldTypeDefinition(session, argument.type, argument.typeName);
    writer.write(platform.getProcedureArgumentString());
    if (platform.shouldPrintInputTokenAtStart()) {
        writer.write(" ");
        writer.write(platform.getInputProcedureToken());
        writer.write(" ");
    }
    writer.write(argument.name);
    writer.write(" ");
    writer.write(fieldType.getName());
    if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) {
        writer.write("(");
        if (argument.size == 0) {
            writer.write(Integer.toString(fieldType.getDefaultSize()));
        } else {
            writer.write(Integer.toString(argument.size));
        }
        if (argument.subSize != 0) {
            writer.write(",");
            writer.write(Integer.toString(argument.subSize));
        } else if (fieldType.getDefaultSubSize() != 0) {
            writer.write(",");
            writer.write(Integer.toString(fieldType.getDefaultSubSize()));
        }
        writer.write(")");
    }
}
Also used : FieldTypeDefinition(org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition) DatabasePlatform(org.eclipse.persistence.internal.databaseaccess.DatabasePlatform)

Example 5 with FieldTypeDefinition

use of org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition in project eclipselink by eclipse-ee4j.

the class StoredProcedureDefinition method printInOutputArgument.

/**
 * Print the argument and its type.
 * @param argument Stored procedure argument.
 * @param writer   Target writer where to write argument string.
 * @param session  Current session context.
 * @throws ValidationException When invalid or inconsistent data were found.
 */
protected void printInOutputArgument(final FieldDefinition argument, final Writer writer, final AbstractSession session) throws ValidationException {
    try {
        final DatabasePlatform platform = session.getPlatform();
        final FieldTypeDefinition fieldType = getFieldTypeDefinition(session, argument.type, argument.typeName);
        writer.write(platform.getProcedureArgumentString());
        if (platform.shouldPrintOutputTokenAtStart()) {
            writer.write(" ");
            writer.write(platform.getCreationInOutputProcedureToken());
            writer.write(" ");
        }
        writer.write(argument.name);
        if ((!platform.shouldPrintOutputTokenAtStart()) && platform.shouldPrintOutputTokenBeforeType()) {
            writer.write(" ");
            writer.write(platform.getCreationInOutputProcedureToken());
        }
        writer.write(" ");
        writer.write(fieldType.getName());
        if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) {
            writer.write("(");
            if (argument.size == 0) {
                writer.write(Integer.toString(fieldType.getDefaultSize()));
            } else {
                writer.write(Integer.toString(argument.size));
            }
            if (argument.subSize != 0) {
                writer.write(",");
                writer.write(Integer.toString(argument.subSize));
            } else if (fieldType.getDefaultSubSize() != 0) {
                writer.write(",");
                writer.write(Integer.toString(fieldType.getDefaultSubSize()));
            }
            writer.write(")");
        }
        if ((!platform.shouldPrintOutputTokenAtStart()) && (!platform.shouldPrintOutputTokenBeforeType())) {
            writer.write(" ");
            writer.write(platform.getCreationInOutputProcedureToken());
        }
    } catch (IOException ioException) {
        throw ValidationException.fileError(ioException);
    }
}
Also used : FieldTypeDefinition(org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition) DatabasePlatform(org.eclipse.persistence.internal.databaseaccess.DatabasePlatform) IOException(java.io.IOException)

Aggregations

FieldTypeDefinition (org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition)36 Hashtable (java.util.Hashtable)13 DatabasePlatform (org.eclipse.persistence.internal.databaseaccess.DatabasePlatform)5 IOException (java.io.IOException)4 java.util (java.util)3 Map (java.util.Map)2 PrivilegedActionException (java.security.PrivilegedActionException)1 java.sql (java.sql)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ConversionException (org.eclipse.persistence.exceptions.ConversionException)1 DatabaseException (org.eclipse.persistence.exceptions.DatabaseException)1 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)1 ValidationException (org.eclipse.persistence.exceptions.ValidationException)1 DescriptorIterator (org.eclipse.persistence.internal.descriptors.DescriptorIterator)1 FieldTransformation (org.eclipse.persistence.internal.descriptors.FieldTransformation)1 MethodBasedFieldTransformation (org.eclipse.persistence.internal.descriptors.MethodBasedFieldTransformation)1 TransformerBasedFieldTransformation (org.eclipse.persistence.internal.descriptors.TransformerBasedFieldTransformation)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 PrivilegedNewInstanceFromClass (org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass)1