Search in sources :

Example 16 with DatabaseType

use of org.eclipse.persistence.internal.helper.DatabaseType in project eclipselink by eclipse-ee4j.

the class PLSQLStoredProcedureCall method addNamedArgument.

/**
 * PUBLIC:
 * Add a named IN argument to the stored procedure. The databaseType parameter classifies the
 * parameter (JDBCType vs. OraclePLSQLType, simple vs. complex). The extra scale and precision
 * parameters indicates that this parameter, when used in an Anonymous PL/SQL block, requires
 * scale and precision specification
 */
public void addNamedArgument(String procedureParameterName, DatabaseType databaseType, int precision, int scale) {
    DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType) databaseType).clone() : databaseType;
    arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, IN, dt, precision, scale));
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType)

Example 17 with DatabaseType

use of org.eclipse.persistence.internal.helper.DatabaseType in project eclipselink by eclipse-ee4j.

the class PLSQLParameterMetadata method process.

/**
 * INTERNAL:
 */
public void process(PLSQLStoredProcedureCall call, boolean functionReturn) {
    // Process the procedure parameter name, defaults to the
    // argument field name.
    // TODO: Log a message when defaulting.
    String procedureParameterName = m_name;
    if (m_name == null || m_name.equals("")) {
        procedureParameterName = m_queryParameter;
    }
    if ((m_optional != null) && m_optional) {
        call.addOptionalArgument(procedureParameterName);
    }
    DatabaseType type = getDatabaseTypeEnum(getDatabaseType());
    // Process the parameter direction
    if (functionReturn) {
        // check for cursor return type
        if (Direction.OUT_CURSOR.name().equals(m_direction)) {
            // the constructor by default adds a RETURN argument, so remove it
            call.getArguments().remove(0);
            call.useNamedCursorOutputAsResultSet(Direction.OUT_CURSOR.name(), type);
        } else {
            if (getLength() != null) {
                ((PLSQLStoredFunctionCall) call).setResult(type, getLength());
            } else if (getPrecision() != null) {
                ((PLSQLStoredFunctionCall) call).setResult(type, getPrecision(), getScale());
            } else {
                ((PLSQLStoredFunctionCall) call).setResult(type);
            }
        }
    } else if (m_direction == null || m_direction.equals(Direction.IN.name())) {
        // TODO: Log a defaulting message if m_direction is null.
        if (getLength() != null) {
            call.addNamedArgument(procedureParameterName, type, getLength());
        } else if (getPrecision() != null) {
            call.addNamedArgument(procedureParameterName, type, getPrecision(), getScale());
        } else {
            call.addNamedArgument(procedureParameterName, type);
        }
    } else if (m_direction.equals(Direction.OUT.name())) {
        if (getLength() != null) {
            call.addNamedOutputArgument(procedureParameterName, type, getLength());
        } else if (getPrecision() != null) {
            call.addNamedOutputArgument(procedureParameterName, type, getPrecision(), getScale());
        } else {
            call.addNamedOutputArgument(procedureParameterName, type);
        }
    } else if (m_direction.equals(Direction.IN_OUT.name())) {
        if (getLength() != null) {
            call.addNamedInOutputArgument(procedureParameterName, type, getLength());
        } else if (getPrecision() != null) {
            call.addNamedInOutputArgument(procedureParameterName, type, getPrecision(), getScale());
        } else {
            call.addNamedInOutputArgument(procedureParameterName, type);
        }
    } else if (m_direction.equals(Direction.OUT_CURSOR.name())) {
        boolean multipleCursors = false;
        if (call.getParameterTypes().contains(DatasourceCall.OUT_CURSOR)) {
            multipleCursors = true;
        }
        call.useNamedCursorOutputAsResultSet(procedureParameterName, type);
        // There are multiple cursor output parameters, then do not use the cursor as the result set.
        if (multipleCursors) {
            call.setIsCursorOutputProcedure(false);
        }
    }
}
Also used : PLSQLStoredFunctionCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredFunctionCall) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType)

Aggregations

DatabaseType (org.eclipse.persistence.internal.helper.DatabaseType)17 ComplexDatabaseType (org.eclipse.persistence.internal.helper.ComplexDatabaseType)14 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)4 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)4 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)4 ArrayList (java.util.ArrayList)3 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)3 OracleObjectType (org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType)3 HashMap (java.util.HashMap)2 OracleArrayType (org.eclipse.persistence.platform.database.oracle.jdbc.OracleArrayType)2 PLSQLargument (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLargument)2 EntityManager (jakarta.persistence.EntityManager)1 Query (jakarta.persistence.Query)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 DatabaseCall (org.eclipse.persistence.internal.databaseaccess.DatabaseCall)1 SoftIdentityMap (org.eclipse.persistence.internal.identitymaps.SoftIdentityMap)1