Search in sources :

Example 11 with PLSQLCollection

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection in project eclipselink by eclipse-ee4j.

the class PLSQLProject method buildCityListOutQuery.

protected DatabaseQuery buildCityListOutQuery() {
    PLSQLCollection collection = new PLSQLCollection();
    collection.setTypeName("PLSQL_P.PLSQL_CITY_LIST");
    collection.setCompatibleType("PLSQL_P_PLSQL_CITY_LIST");
    collection.setNestedType(JDBCTypes.VARCHAR_TYPE);
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("PLSQL_P.PLSQL_CITY_LIST_OUT");
    call.addNamedOutputArgument("P_CITY_LIST", collection);
    call.addNamedOutputArgument("P_CITY", JDBCTypes.VARCHAR_TYPE);
    DataReadQuery query = new DataReadQuery();
    query.setCall(call);
    return query;
}
Also used : PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) DataReadQuery(org.eclipse.persistence.queries.DataReadQuery)

Example 12 with PLSQLCollection

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection in project eclipselink by eclipse-ee4j.

the class PLSQLProject method buildAddressListInQuery.

protected DatabaseQuery buildAddressListInQuery() {
    PLSQLrecord record = buildAddressRecord();
    PLSQLCollection collection = new PLSQLCollection();
    collection.setTypeName("PLSQL_P.PLSQL_ADDRESS_LIST");
    collection.setCompatibleType("PLSQL_P_PLSQL_ADDRESS_LIST");
    collection.setNestedType(record);
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("PLSQL_P.PLSQL_ADDRESS_LIST_IN");
    call.addNamedArgument("P_ADDRESS_LIST", collection);
    call.addNamedArgument("P_CITY", JDBCTypes.VARCHAR_TYPE);
    DataModifyQuery query = new DataModifyQuery();
    query.addArgument("P_ADDRESS_LIST", java.sql.Array.class);
    query.addArgument("P_CITY", String.class);
    query.setCall(call);
    return query;
}
Also used : PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery)

Example 13 with PLSQLCollection

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection in project eclipselink by eclipse-ee4j.

the class PLSQLcollectionTestSuite method setUpProject.

@BeforeClass
public static void setUpProject() {
    final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    username = System.getProperty(DATABASE_USERNAME_KEY);
    if (username == null) {
        fail("error retrieving database username");
    }
    password = System.getProperty(DATABASE_PASSWORD_KEY);
    if (password == null) {
        fail("error retrieving database password");
    }
    url = System.getProperty(DATABASE_URL_KEY);
    if (url == null) {
        fail("error retrieving database url");
    }
    project = new Project();
    project.setName("PLSQLcollectionTestSuite");
    ObjectRelationalDataTypeDescriptor t1Descriptor = new ObjectRelationalDataTypeDescriptor();
    t1Descriptor.setAlias("T1");
    t1Descriptor.setJavaClassName("org.eclipse.persistence.testing.tests.plsqlcollection.T1");
    t1Descriptor.descriptorIsAggregate();
    t1Descriptor.getQueryManager();
    project.addDescriptor(t1Descriptor);
    PLSQLCollection simplArray = new PLSQLCollection();
    simplArray.setTypeName("SOMEPACKAGE.TBL1");
    simplArray.setCompatibleType("SOMEPACKAGE_TBL1");
    simplArray.setNestedType(JDBCTypes.VARCHAR_TYPE);
    PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
    call.setProcedureName("SOMEPACKAGE.P1");
    call.addNamedArgument("SIMPLARRAY", simplArray);
    call.addNamedArgument("FOO", JDBCTypes.VARCHAR_TYPE, 10);
    DataModifyQuery query = new DataModifyQuery();
    query.addArgument("SIMPLARRAY", Array.class);
    query.addArgument("FOO", String.class);
    query.setCall(call);
    t1Descriptor.getQueryManager().addQuery(QUERY_NAME, query);
    if (ddlCreate) {
        try {
            AllTests.runDdl(CREATE_DDL, ddlDebug);
        } catch (Exception e) {
        // e.printStackTrace();
        }
    }
}
Also used : ObjectPersistenceWorkbenchXMLProject(org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject) Project(org.eclipse.persistence.sessions.Project) PLSQLStoredProcedureCall(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) ObjectRelationalDataTypeDescriptor(org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery) BeforeClass(org.junit.BeforeClass)

Example 14 with PLSQLCollection

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject_11_1_1 method buildPLSQLCollectionDescriptor.

protected ClassDescriptor buildPLSQLCollectionDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PLSQLCollection.class);
    XMLDirectMapping typeNameMapping = new XMLDirectMapping();
    typeNameMapping.setAttributeName("typeName");
    typeNameMapping.setXPath(getPrimaryNamespaceXPath() + "type-name/text()");
    descriptor.addMapping(typeNameMapping);
    XMLDirectMapping compatibleTypeMapping = new XMLDirectMapping();
    compatibleTypeMapping.setAttributeName("compatibleType");
    compatibleTypeMapping.setXPath(getPrimaryNamespaceXPath() + "compatible-type/text()");
    descriptor.addMapping(compatibleTypeMapping);
    XMLDirectMapping javaTypeMapping = new XMLDirectMapping();
    javaTypeMapping.setAttributeName("javaType");
    javaTypeMapping.setXPath(getPrimaryNamespaceXPath() + "java-type/text()");
    descriptor.addMapping(javaTypeMapping);
    XMLCompositeObjectMapping databaseTypeMapping = new XMLCompositeObjectMapping();
    databaseTypeMapping.setAttributeName("databaseTypeWrapper");
    databaseTypeMapping.setAttributeAccessor(new AttributeAccessor() {

        @Override
        public Object getAttributeValueFromObject(Object object) {
            PLSQLCollection collection = (PLSQLCollection) object;
            DatabaseType type = collection.getNestedType();
            return wrapType(type);
        }

        @Override
        public void setAttributeValueInObject(Object object, Object value) {
            PLSQLCollection collection = (PLSQLCollection) object;
            DatabaseTypeWrapper type = (DatabaseTypeWrapper) value;
            collection.setNestedType(type.getWrappedType());
        }
    });
    databaseTypeMapping.setReferenceClass(DatabaseTypeWrapper.class);
    databaseTypeMapping.setXPath("nested-type");
    descriptor.addMapping(databaseTypeMapping);
    XMLDirectMapping isNestedTableMapping = new XMLDirectMapping();
    isNestedTableMapping.setAttributeName("isNestedTable");
    isNestedTableMapping.setXPath("@is-nested-table");
    isNestedTableMapping.setNullValue(Boolean.FALSE);
    descriptor.addMapping(isNestedTableMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) DatabaseType(org.eclipse.persistence.internal.helper.DatabaseType) ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) AttributeAccessor(org.eclipse.persistence.mappings.AttributeAccessor) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 15 with PLSQLCollection

use of org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection in project eclipselink by eclipse-ee4j.

the class PLSQLTableMetadata method process.

/**
 * INTERNAL:
 * Build a runtime record type from the meta-data.
 */
@Override
public PLSQLCollection process() {
    PLSQLCollection table = new PLSQLCollection();
    super.process(table);
    table.setIsNestedTable(isNestedTable());
    table.setNestedType(getDatabaseTypeEnum(getNestedType()));
    return table;
}
Also used : PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection)

Aggregations

PLSQLCollection (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection)16 PLSQLStoredProcedureCall (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLStoredProcedureCall)12 PLSQLrecord (org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord)10 DataReadQuery (org.eclipse.persistence.queries.DataReadQuery)8 DataModifyQuery (org.eclipse.persistence.queries.DataModifyQuery)4 ComplexDatabaseType (org.eclipse.persistence.internal.helper.ComplexDatabaseType)3 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)2 OracleObjectType (org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType)2 CompositeDatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)2 DatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType)2 PLSQLCollectionType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCollectionType)2 VArrayType (org.eclipse.persistence.tools.oracleddl.metadata.VArrayType)2 Struct (java.sql.Struct)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DatabaseType (org.eclipse.persistence.internal.helper.DatabaseType)1 ObjectPersistenceWorkbenchXMLProject (org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject)1 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)1 ObjectRelationalDataTypeDescriptor (org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor)1