Search in sources :

Example 6 with DatabaseType

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

the class PLSQLStoredProcedureCall method buildNestedFunctions.

/**
 * INTERNAL
 * Generate portion of the Anonymous PL/SQL block with PL/SQL conversion routines as
 * nested functions.
 */
protected void buildNestedFunctions(StringBuilder stream, List<PLSQLargument> arguments) {
    List<String> nestedFunctions = new ArrayList<>();
    Set<DatabaseType> processed = new HashSet<>();
    for (PLSQLargument arg : arguments) {
        DatabaseType type = arg.databaseType;
        addNestedFunctionsForArgument(nestedFunctions, arg, type, processed);
    }
    if (!nestedFunctions.isEmpty()) {
        for (String function : nestedFunctions) {
            stream.append(function);
        }
    }
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 7 with DatabaseType

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

the class PLSQLStoredProcedureCall method addNamedOutputArgument.

/**
 * PUBLIC: Add a named OUT argument to the stored procedure. The databaseType parameter
 * classifies the parameter (JDBCType vs. OraclePLSQLType, simple vs. complex)
 */
public void addNamedOutputArgument(String procedureParameterName, DatabaseType databaseType) {
    DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType) databaseType).clone() : databaseType;
    arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, OUT, dt));
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType)

Example 8 with DatabaseType

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

the class PLSQLStoredProcedureCall method addNestedFunctionsForArgument.

/**
 * INTERNAL
 * Add the nested function string required for the type and its subtypes. The functions
 * must be added in inverse order to resolve dependencies.
 */
protected void addNestedFunctionsForArgument(List<String> functions, PLSQLargument argument, DatabaseType databaseType, Set<DatabaseType> processed) {
    if ((databaseType == null) || !databaseType.isComplexDatabaseType() || databaseType.isJDBCType() || argument.cursorOutput || processed.contains(databaseType)) {
        return;
    }
    ComplexDatabaseType type = (ComplexDatabaseType) databaseType;
    if (!type.hasCompatibleType()) {
        return;
    }
    processed.add(type);
    boolean isNestedTable = false;
    if (type.isCollection()) {
        isNestedTable = ((PLSQLCollection) type).isNestedTable();
        DatabaseType nestedType = ((PLSQLCollection) type).getNestedType();
        addNestedFunctionsForArgument(functions, argument, nestedType, processed);
    } else if (type.isRecord()) {
        for (PLSQLargument field : ((PLSQLrecord) type).getFields()) {
            DatabaseType nestedType = field.databaseType;
            addNestedFunctionsForArgument(functions, argument, nestedType, processed);
        }
    }
    TypeInfo info = this.typesInfo.get(type.getTypeName());
    // If the info was not found in publisher, then generate it.
    if (info == null) {
        info = generateNestedFunction(type, isNestedTable);
    }
    if (type.getTypeName().equals(type.getCompatibleType())) {
        if (!functions.contains(info.pl2SqlConv)) {
            functions.add(info.pl2SqlConv);
        }
    } else {
        if (argument.direction == IN) {
            if (!functions.contains(info.sql2PlConv)) {
                functions.add(info.sql2PlConv);
            }
        } else if (argument.direction == INOUT) {
            if (!functions.contains(info.sql2PlConv)) {
                functions.add(info.sql2PlConv);
            }
            if (!functions.contains(info.pl2SqlConv)) {
                functions.add(info.pl2SqlConv);
            }
        } else if (argument.direction == OUT) {
            if (!functions.contains(info.pl2SqlConv)) {
                functions.add(info.pl2SqlConv);
            }
        }
    }
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType) ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType)

Example 9 with DatabaseType

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

the class PLSQLStoredProcedureCall method addNamedOutputArgument.

/**
 * PUBLIC: Add a named OUT 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 addNamedOutputArgument(String procedureParameterName, DatabaseType databaseType, int precision, int scale) {
    DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType) databaseType).clone() : databaseType;
    arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, OUT, dt, precision, scale));
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType)

Example 10 with DatabaseType

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

the class PLSQLStoredProcedureCall method addNamedInOutputArgument.

/**
 * PUBLIC: Add a named IN OUT argument to the stored procedure. The databaseType parameter
 * classifies the parameter (JDBCType vs. OraclePLSQLType, simple vs. complex)
 */
public void addNamedInOutputArgument(String procedureParameterName, DatabaseType databaseType) {
    DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType) databaseType).clone() : databaseType;
    arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, INOUT, dt));
}
Also used : ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) 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