Search in sources :

Example 1 with ObjectRelationalDatabaseField

use of org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField in project eclipselink by eclipse-ee4j.

the class StoredProcedureParameterMetadata method buildNestedField.

/**
 * Builds an ObjectRelationalDatabaseField based on a given OracleArrayTypeMetadata
 * instance.
 *
 * @param aType OracleArrayTypeMetadata instance to be used to construct the field
 * @return an ObjectRelationalDatabaseField instance
 */
protected ObjectRelationalDatabaseField buildNestedField(OracleArrayTypeMetadata aType) {
    ObjectRelationalDatabaseField dbFld = new ObjectRelationalDatabaseField("");
    String nestedType = aType.getNestedType();
    dbFld.setSqlTypeName(nestedType);
    for (OracleObjectTypeMetadata oType : getEntityMappings().getOracleObjectTypes()) {
        if (oType.getName().equals(nestedType)) {
            dbFld.setSqlType(STRUCT);
            dbFld.setTypeName(oType.getJavaType());
        }
    }
    return dbFld;
}
Also used : ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField)

Example 2 with ObjectRelationalDatabaseField

use of org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField in project eclipselink by eclipse-ee4j.

the class ArrayAccessor method process.

/**
 * INTERNAL:
 * Process the ArrayMapping or ObjectArrayMapping.
 */
@Override
public void process() {
    if (isDirectEmbeddableCollection()) {
        ObjectArrayMapping mapping = new ObjectArrayMapping();
        // Add the mapping to the descriptor.
        setMapping(mapping);
        // Set the reference class name.
        mapping.setReferenceClassName(getReferenceClassName());
        // Set the attribute name.
        mapping.setAttributeName(getAttributeName());
        // Will check for PROPERTY access
        setAccessorMethods(mapping);
        mapping.setStructureName(getDatabaseType());
        // Process the @Column or column element if there is one.
        // A number of methods depend on this field so it must be
        // initialized before any further processing can take place.
        mapping.setField(new ObjectRelationalDatabaseField(getDatabaseField(getDescriptor().getPrimaryTable(), MetadataLogger.COLUMN)));
    } else {
        ArrayMapping mapping = new ArrayMapping();
        // Add the mapping to the descriptor.
        setMapping(mapping);
        // Set the attribute name.
        mapping.setAttributeName(getAttributeName());
        // Will check for PROPERTY access
        setAccessorMethods(mapping);
        mapping.setStructureName(getDatabaseType());
        // Process the @Column or column element if there is one.
        // A number of methods depend on this field so it must be
        // initialized before any further processing can take place.
        mapping.setField(new ObjectRelationalDatabaseField(getDatabaseField(getDescriptor().getPrimaryTable(), MetadataLogger.COLUMN)));
    }
}
Also used : ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) ObjectArrayMapping(org.eclipse.persistence.mappings.structures.ObjectArrayMapping) ArrayMapping(org.eclipse.persistence.mappings.structures.ArrayMapping) ObjectArrayMapping(org.eclipse.persistence.mappings.structures.ObjectArrayMapping)

Example 3 with ObjectRelationalDatabaseField

use of org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField in project eclipselink by eclipse-ee4j.

the class StructureAccessor method process.

/**
 * INTERNAL:
 * Build and structure mapping and add it to the descriptor.
 */
@Override
public void process() {
    StructureMapping mapping = new StructureMapping();
    setMapping(mapping);
    // Process the @Column or column element if there is one.
    // A number of methods depend on this field so it must be
    // initialized before any further processing can take place.
    m_field = new ObjectRelationalDatabaseField(getDatabaseField(getDescriptor().getPrimaryTable(), MetadataLogger.COLUMN));
    mapping.setField(m_field);
    mapping.setIsReadOnly(m_field.isReadOnly());
    mapping.setReferenceClassName(getReferenceClassName());
    mapping.setAttributeName(getAttributeName());
    // Will check for PROPERTY access
    setAccessorMethods(mapping);
    // Process a @ReturnInsert and @ReturnUpdate (to log a warning message)
    processReturnInsertAndUpdate();
}
Also used : ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) StructureMapping(org.eclipse.persistence.mappings.structures.StructureMapping)

Example 4 with ObjectRelationalDatabaseField

use of org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField in project eclipselink by eclipse-ee4j.

the class DatabasePlatform method setNullFromDatabaseField.

protected void setNullFromDatabaseField(DatabaseField databaseField, CallableStatement statement, String name) throws SQLException {
    // user defined type to setNull as well.
    if (databaseField instanceof ObjectRelationalDatabaseField) {
        ObjectRelationalDatabaseField field = (ObjectRelationalDatabaseField) databaseField;
        statement.setNull(name, field.getSqlType(), field.getSqlTypeName());
    } else {
        int jdbcType = getJDBCTypeForSetNull(databaseField);
        statement.setNull(name, jdbcType);
    }
}
Also used : ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField)

Example 5 with ObjectRelationalDatabaseField

use of org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField in project eclipselink by eclipse-ee4j.

the class DatabasePlatform method setNullFromDatabaseField.

protected void setNullFromDatabaseField(DatabaseField databaseField, PreparedStatement statement, int index) throws SQLException {
    // user defined type to setNull as well.
    if (databaseField instanceof ObjectRelationalDatabaseField) {
        ObjectRelationalDatabaseField field = (ObjectRelationalDatabaseField) databaseField;
        statement.setNull(index, field.getSqlType(), field.getSqlTypeName());
    } else {
        int jdbcType = getJDBCTypeForSetNull(databaseField);
        statement.setNull(index, jdbcType);
    }
}
Also used : ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField)

Aggregations

ObjectRelationalDatabaseField (org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField)36 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)6 StoredProcedureCall (org.eclipse.persistence.queries.StoredProcedureCall)6 ObjectRelationalDataTypeDescriptor (org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor)4 ArrayList (java.util.ArrayList)3 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)3 DatabaseCall (org.eclipse.persistence.internal.databaseaccess.DatabaseCall)3 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)3 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)3 Method (java.lang.reflect.Method)2 Array (java.sql.Array)2 SQLException (java.sql.SQLException)2 Struct (java.sql.Struct)2 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)2 ComplexDatabaseType (org.eclipse.persistence.internal.helper.ComplexDatabaseType)2 ObjectArrayMapping (org.eclipse.persistence.mappings.structures.ObjectArrayMapping)2 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)2 SQLCall (org.eclipse.persistence.queries.SQLCall)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringReader (java.io.StringReader)1